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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PowerBITesting
Helper IV
Helper IV

Date slicer - Date difference in days

Title =
var Lable= "Avg sales per day "
var DateRangeYear =CALCULATE(DATEDIFF(Min(activitypointers[createdon]),MAX(activitypointers[createdon]),YEAR))
var DateRangeMonth =CALCULATE(DATEDIFF(Min(activitypointers[createdon]),MAX(activitypointers[createdon]),MONTH))
var DateRangeDate =CALCULATE(DATEDIFF(Min(activitypointers[createdon]),MAX(activitypointers[createdon]),DAY))
Var years=" Years"
Var Months=" Months"
Var Days=" Days"
return
if(DateRangeYear<>0,Lable & DateRangeYear & years,if(DateRangeMonth<>0,Lable & DateRangeMonth & Months,Lable & DateRangeDate & Days))
 
Date range date comes always zero - I am not able to get Date difference by Days. 
Month and year is working . 
3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi @PowerBITesting 

I have tested on my side, this formula works well

2.JPG

 

could you please share your sample pbix file for us have a test, there should be something wrong in other.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@PowerBITesting , this should have given you

CALCULATE(DATEDIFF(Min(activitypointers[createdon]),MAX(activitypointers[createdon]),DAY))

 

Check the datatype too

 

Can you share sample data and sample output in table format?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@PowerBITesting - That's very odd, can you share the PBIX?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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