Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

IF function based on date

Hi all,

Have a DAX calculation I need to create, was hoping I could get some help with it. I have the below table for a recruiter. It looks at employees, the date they're leaving the company, and the fee associated with their leaving.

 

I need to create a DAX calculation that takes the first 8 employees with values for Y_Fee_Calc (ie > 0) based on leavedate and gives the result "CAP", otherwise "NOCAP".

 

So in this dummy data below, it would take the first 8 based on their leave date (down as far as Michelle Harris) and give them "CAP", the last two would have "NOCAP". Is this possible?

 

custerdome_1-1679903065830.png

 

 

 

 

Thanks!

3 REPLIES 3
wdx223_Daniel
Community Champion
Community Champion

NewColumn=VAR _n=Table[FullName] RETURN IF(Table[Y_Fee_Calc]=0||COUNTROWS(FILTER(TOPN(8,FILTER(Table,Table[Y_Fee_Calc]>0),Table[Leavedate],ASC,Table[Y_Fee_Calc],DESC),Table[FullName]=_n)=0,"NOCAP","CAP")

Anonymous
Not applicable

Thank you so much for the quick reply! The calculation is definitely on the right track, but I seem to be getting an error when I enter it - COUNTROWS has too many filters, the maximum is 1. Is there any  way around this?

 

Thanks again! 

please show your real code

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.