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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Date difference in Report between measure and table column

Hi,

 

I have following to date column in report, Completed Date is a measure and the started date is the earliest started date from table.

 

Now I want to subtract them in a way that if completed is blank then now()-started date else completed - started date.

 

The problem is when I display days worked measure my all table data gets disappeared, and I am not sure why.

 

Following is my DAX Command for Measure Days Worked :

Days Worked = if(ISBLANK([Measure]),DATEDIFF(NOW(),Max(G6_SampleData[Started Date]),DAY),datediff([Measure],Max(G6_SampleData[Started Date]), DAY))

And Following is my DAX Command for Measure Completed Date:
 
Measure = IF(CALCULATE(COUNTROWS(SampleData),FILTER(SampleData,SampleData[Job Completion Date]=BLANK())) > 0, BLANK(), MAX(SampleData[Job Completion Date]))

 

Hunain_0-1608775296924.png

Hunain_1-1608775517304.png

 

Please let me know how can I resolve this issue. Thanks

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like


Days Worked =
var _1 = IF(ISBLANK([Measure]),BLANK(),DATEDIFF(MIN(SampleData[Started Date]),[Measure],DAY))
return
if(isblank(_1) , DATEDIFF(MIN(SampleData[Started Date]),now(),DAY),_1)

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 , Try like


Days Worked =
var _1 = IF(ISBLANK([Measure]),BLANK(),DATEDIFF(MIN(SampleData[Started Date]),[Measure],DAY))
return
if(isblank(_1) , DATEDIFF(MIN(SampleData[Started Date]),now(),DAY),_1)

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 , if they are from same tbale you can create a new column

new column = datediff(coalesce([Job Completion Date], now()),[Started Date],day)

 

if you need a measure of they are from different table, You need a common context like job id, then you can create a meausre
New measure = sumx(values(JOB[JOB ID]),datediff(coalesce(max([Job Completion Date]), now()),min([Started Date]),day))
New measure = AverageX(values(JOB[JOB ID]),datediff(coalesce(max([Job Completion Date]), now()),min([Started Date]),day))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi, 

 

The measure you provided didn't work for me. 

 

However I have wrote the below DAX in measure and it is working:

 

Days Worked = IF(ISBLANK([Measure]),BLANK(),DATEDIFF(MIN(SampleData[Started Date]),[Measure],DAY))

 

Now the olny problem is where I have BLANK(), I want to replace that with now - SampleData[Started Date] but when I do that the data again gets disappeared and wrong values displays in Days Worked Column.Screenshot.png

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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