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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply

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
v-yilong-msft
Community Support
Community Support

Hi @FlankyPank2___ ,

I create a table as you mentioned.

vyilongmsft_0-1721620337047.png

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

vyilongmsft_1-1721620594979.png

 

 

 

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.

View solution in original post

4 REPLIES 4
v-yilong-msft
Community Support
Community Support

Hi @FlankyPank2___ ,

I create a table as you mentioned.

vyilongmsft_0-1721620337047.png

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

vyilongmsft_1-1721620594979.png

 

 

 

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.

I Can' thank you enough - That works wonderfully

Joe_Barry
Super User
Super User

Hi @FlankyPank2___ 

 

Why not try TODAY() instead of Max Date?

 

Joe




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Hi,  thanks for replying.

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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