cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper I

## Datediff count using a slicer - unless it'd up-to todays date?

Hi,

Sorry I'm useless.  I cant figure this out.

I have this measure which works well but I don't wan't it to count up past todays date.  Is it possible to amend this dax to do that?

Slicer Day Count 24-25 = var _max = maxx(ALLSELECTED('Date24-25'),'Date24-25'[Date]) var _min = minx(ALLSELECTED('Date24-25'),'Date24-25'[Date]) return datediff(_min,_max,day)+1

Thank you.

1 ACCEPTED SOLUTION
Community Support

I create a table as you mentioned.

Then I create a measure and here is the DAX code.

``````Measure =
VAR _max =
MIN ( TODAY (), MAXX ( ALLSELECTED ( 'Date24-25' ), 'Date24-25'[Date] ) )
VAR _min =
MINX ( ALLSELECTED ( 'Date24-25' ), 'Date24-25'[Date] )
RETURN
DATEDIFF ( _min, _max, DAY ) + 1``````

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 REPLIES 4
Community Support

I create a table as you mentioned.

Then I create a measure and here is the DAX code.

``````Measure =
VAR _max =
MIN ( TODAY (), MAXX ( ALLSELECTED ( 'Date24-25' ), 'Date24-25'[Date] ) )
VAR _min =
MINX ( ALLSELECTED ( 'Date24-25' ), 'Date24-25'[Date] )
RETURN
DATEDIFF ( _min, _max, DAY ) + 1``````

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper I

I Can' thank you enough - That works wonderfully

Super User

Why not try TODAY() instead of Max Date?

Joe

Proud to be a Super User!

Learn about the Star Schema, it will solve many issues in Power BI!

Helper I

I've tried adding in today() in various places but tbh I dont understand the majority of dax yet & i'm just winging it.

i'll get there.

Thank you

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors