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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
arc_gts
Frequent Visitor

Compairing a date measure to a date column in the same dimension table

I'm trying to create a filter to determine the inclusion or exclusion of records in a dimension table based on whether the Threshold Date for each record is less than the calculated Last Date measure. There's probably a much more intelligent way to do this, but I'm kind of stumbling my way around here and am not very good with DAX.

 

The threshold date column is native to the imported Excel spreadsheet that I'm using as a dimension table; the measure is based on a calendar dimension table imported from a data warehouse, and I'm selecting date ranges using a date slicer in the report. I've tried calculating the Last Date two different ways:

 

1) Using CALCULATE and LASTDATE: CALCULATE(LASTDATE('Calendar'[Date (EDW)]), ALLSELECTED('Calendar'[Date (EDW)]))
2) Using MAXX: MAXX(ALLSELECTED('Calendar'),'Calendar'[Date (EDW)])
 
Both work fine as measures. If I try to convert them into dimensions (or create them as columns instead of measures), they'll ignore the slicer and just return the last date from my entire calendar table. Similarly, if I try to create an IF statement returning a one or zero based on whether the Threshold Date falls before the Last Date, the formula returns a value of one for all records in the dimension table with a Threshold Date that falls before the last date in my calendar table.
 
Is there a way to compare my Last Date and Threshold Date that will still apply the slicer to the Last Date?
 
I can't create an active relationship between the calendar dimension table and the dimension table containing Threshold Dates because the calendar dimension table already joins to two fact tables which then join to the dimension table containing Threshold Dates.
 
1 ACCEPTED SOLUTION

@arc_gts  you can write this two measures

_isThresholdLesserThanLastSelected = if(MAX(Category[Threshold Date])<=[Category last date],0,1)

_isThresholdGTThanLastSelected = if(MAX(Category[Threshold Date])>[Category last date],0,1)

 

smpa01_0-1640827458725.png

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

7 REPLIES 7
arc_gts
Frequent Visitor

PBIX file link

@arc_gts  you can write this two measures

_isThresholdLesserThanLastSelected = if(MAX(Category[Threshold Date])<=[Category last date],0,1)

_isThresholdGTThanLastSelected = if(MAX(Category[Threshold Date])>[Category last date],0,1)

 

smpa01_0-1640827458725.png

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
arc_gts
Frequent Visitor

Goal: add an indicator that I can use as a filter to show or hide rows in a table based on a date in the table vs. a date in a slicer (no direct relationship between date slicer table and dimension table)

 

Expected outcome: rows in the dimension table with a greater date than the maximum selected slicer date value should have a value of zero, while rows in the dimension table with a value less than / equal to the maximum selected slicer date value should have a value of 1

 

Actual outcome: rows in the dimension table that have date value that exists in the calendar table have a value of 1, ignoring the selected range in the slicer; rows in the dimension table that have a date value that doesn't exist in the calendar table (greater than the max date value) have a value of zero

 

Please see below. It looks like I'm unable to upload a PBIX file.

 

image.png

Try this Click here to download PBIX 

 

 

Thanks.

 

You cant upload PBIX to the forum.

You need to save it on Onedrop or Dropbox with public view access and then share the link on the forum.

 

smpa01
Super User
Super User

@arc_gts provide sample data and expected output

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
speedramps
Community Champion
Community Champion

Hi

 

Sorry I dont understand you.

 

May I suggest rather than you try explain you rsolution (which does not work and you want us to fix).

 

That you simply explain the problem more clearly and with an exmaple, then I am sure we can all help you with this date filter issue.

 

Thanks 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.