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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX - compare dates against unrelated date table?

Hi, hopefully someone can help with this.

I have an SSAS tabular model and I am trying to add a dynamic calculated column which will set to 1 if the ClosedDate > Start of selected month, and the CreatedDate < start of selected month.

I have the following DAX however this isn't setting the flag for some reason? Does anyone know what I am doing wrong?

=
VAR __mindate =
STARTOFMONTH('Date'[FullDate])
RETURN

IF(Query[DateClosed]>= __mindate && Query[DateAdded] < __mindate,1,0)example.PNG

So for the attached example, VAR __mindate should be set to '01-jul-2021' (as this month is what is selected in my slicer) and then flag should be set to 1 on the IDs 3971, 3964 and 3967 as these 3 rows meet the condition. It is currently setting them all to 0.


1 ACCEPTED SOLUTION
nvprasad
Solution Sage
Solution Sage

Hi JD09631,

If you are trying to create a measure then you need to wrap it with selectedvalue.

 

Could you please try with below dax?

 

VAR __mindate =
STARTOFMONTH('Date'[FullDate])
RETURN

IF(selectedvaue(Query[DateClosed])>= __mindate && selectevaue(Query[DateAdded] )< __mindate,1,0)

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

For my own understanding & learning, would this have even been achievable as a calculated column?

nvprasad
Solution Sage
Solution Sage

Hi JD09631,

If you are trying to create a measure then you need to wrap it with selectedvalue.

 

Could you please try with below dax?

 

VAR __mindate =
STARTOFMONTH('Date'[FullDate])
RETURN

IF(selectedvaue(Query[DateClosed])>= __mindate && selectevaue(Query[DateAdded] )< __mindate,1,0)

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.
Anonymous
Not applicable

Nevermind I think it works fine, I didn't need to use calculated column afterall this works fine as a measure 🙂

Anonymous
Not applicable

Hi, I am trying to add it as a calculated column. The above isn't working for me still, unfortunately. Still 0 for all rows 😞

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors