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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors