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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Date difference between measure and table column

Hi,

 

I have a report in which I have created one measure (completed date) with following DAX formula:

 

Measure = IF(CALCULATE(COUNTROWS(SampleData),FILTER(SampleData,SampleData[Job Completion Date]=BLANK())) > 0, "", MAX(SampleData[Job Completion Date]))

Now, I have another column which contains Started Date and I want to subtract measure - Started Date, I have tried with following formula:

Measure 2 = DATEDIFF(FORMAT([Measure],"dd/MM/YYYY"), SELECTEDVALUE(G6_SampleData[Started Date].[Date]),DAY)

The reason I have used FORMAT is I am getting an error which states that measure contains "" string. Also when I add measure 2 in my table some rows data gets disappeared. Can anyone please help me with Measure 2 DAX formula ?
 
Thanks.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , change measure like and  change its data type to date

Measure = IF(CALCULATE(COUNTROWS(SampleData),FILTER(SampleData,SampleData[Job Completion Date]=BLANK())) > 0, blank(), MAX(SampleData[Job Completion Date]))

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , change measure like and  change its data type to date

Measure = IF(CALCULATE(COUNTROWS(SampleData),FILTER(SampleData,SampleData[Job Completion Date]=BLANK())) > 0, blank(), MAX(SampleData[Job Completion Date]))

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
amitchandak
Super User
Super User

@Anonymous , You can get it like this

datediff(max(G6_SampleData[Started Date]), [Measure], DAY)

 

But you have force a row context using summarize or values example //assume JOB ID

Sumx(values(G6_SampleData[JOB ID]), datediff(max(G6_SampleData[Started Date]), [Measure], DAY))

 

Averagex(values(G6_SampleData[JOB ID]), datediff(max(G6_SampleData[Started Date]), [Measure], DAY))

 

refer

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Difference-Across/ba-p/934397#M451

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
Anonymous
Not applicable

Thanks Amit,

 

But when I use your provided DAX formula it gives me an error that cannot convert string to Date.

 

Even if use format it gives me the same error.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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