Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi community,
I want to create a measure that calculate the days between the oldest date of my table and a day selection based on date filter.
For insance, using the table below, the oldest date is "01/01/2022" and if I select in my date filter (which is from my same table) "01/09/2022" the result should be 8 days, or if I select in the filter "01/05/2022" the result would be 4.
Dates
Thanks for you help!
Solved! Go to Solution.
Hi @JorgeMolano
What if no selection in the slicer? What do you want to display, the blank? Modify the table and column name accordingly
test =
VAR CurDate=SELECTEDVALUE(DateTable[Dates])
VAR MinDate = MINX(ALL(DateTable[Dates]),DateTable[Dates])
RETURN
DATEDIFF(MinDate,CurDate,DAY)
Hi @JorgeMolano ,
Based on your description, try the following formula.
M_ =
VAR a =
CALCULATE ( MIN ( 'Table'[Date] ), ALL ( 'Table'[Date] ) )
VAR sel_b =
SELECTEDVALUE ( 'Table'[Date] )
RETURN
DATEDIFF ( a, sel_b, DAY )
If the problem is still not resolved, please point it out. Looking forward to your feedback.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Vera,
Thanks for your support, I tried the measure you shared but only shows a consecutive number per each row, dont calculate the number of days between 2 different dates.
Best!
Hi,
The formula suggested by Vera should work for sure. Make sure you write it as a measure (not a calculated column) and drag that measure to a card visual.
Hi @JorgeMolano
It worked here...maybe try ALL(DateTable) instead of the column? Or attach a sample file?
Hi @JorgeMolano
What if no selection in the slicer? What do you want to display, the blank? Modify the table and column name accordingly
test =
VAR CurDate=SELECTEDVALUE(DateTable[Dates])
VAR MinDate = MINX(ALL(DateTable[Dates]),DateTable[Dates])
RETURN
DATEDIFF(MinDate,CurDate,DAY)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
63 | |
53 | |
39 | |
25 |
User | Count |
---|---|
85 | |
57 | |
45 | |
43 | |
38 |