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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
CristinaLia
Frequent Visitor

Measure in Dax with different filters

Hi Everyone,

 

I am new to DAX so I've been struggling with this for a bit. In my report I use the measure below, and it does what I expect it to.

 

UCN Count CY = CALCULATE(
		Trigger[UCN Count],
		FILTER(Trigger,Trigger[TriggerDate].[Year]=year(now())),
		FILTER(Trigger,Trigger[CurrentInd]=True))

 

 

Nevertheless, I realised that for 'Trigger Dates' that are in the past, I don't need to use the second filter (ie FILTER(Trigger,Trigger[CurrentInd]=True)

 

So basically, I want to change this measure to use   Option 1 for any date from today till the end of the year and Option 2 for dates that are this year, but in the past(so from beginning of the year till today). Ideally, I need this in one measure but I;m not sure how to write it to get to the result I want.

 

(FYI UCN Count is a measure, TriggerDate is a date field from my data and CurrentInd is a true/false field from my data)

 

OPTION 1
CALCULATE( Trigger[UCN Count], FILTER(Trigger,Trigger[TriggerDate].[Year]=year(now())), FILTER(Trigger,Trigger[CurrentInd]=True))

OPTION 2
CALCULATE(
Trigger[UCN Count],
FILTER(Trigger,Trigger[TriggerDate].[Year]=year(now())))

I'm not sure if this is enough information, please let me know if you need more on this.

 

Thanks,
Lia

1 ACCEPTED SOLUTION

Would have to see some sample/example data. But, generally you just use an aggregator like MAX or MIN with a column in a measure. As long as the visualization adds the correct filter context then you should be good.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

Perhaps something like:

 

UCN Count CY = IF(<some condition>, 

CALCULATE(
		Trigger[UCN Count],
		FILTER(Trigger,Trigger[TriggerDate].[Year]=year(now())),
		FILTER(Trigger,Trigger[CurrentInd]=True)),

CALCULATE(
		Trigger[UCN Count],
		FILTER(Trigger,Trigger[TriggerDate].[Year]=year(now())))

?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Smoupre,

 

Thank you very much for this, but I'm not sure how to get this right. What you are proposing is actually one of the things I've tried, I used something like IF (Trigger[TriggerDate] > now()) but it doesn't work as TriggerDate is a column, it's not a measure.

 

Any idea how I can get around that? I thought about creating another measure that I can then reference in that IF, but don;t know how

Would have to see some sample/example data. But, generally you just use an aggregator like MAX or MIN with a column in a measure. As long as the visualization adds the correct filter context then you should be good.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

The IF I had in mind works perfectly with adding a MAX on the column I was looking at. It's perfect, thank you very much for your help, I can;t believe I didn;t think of using it before.

 

Thanks again

Awesome, sometimes you just need a second pair of eyes!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.