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! Learn more

Reply
Anonymous
Not applicable

DAX for Period Duration calculation

Hi all

 

I am trying to create a measure that calculates the duration of the period that a claim is outstanding. i.e. when the claim is added to the DB and when the claim is finalised in DB. If the claim is not finalised, then it should calculate the days from the date added to the date selected via a slicer. (I am not sure what to do about the scenario where a date is not selected and the claim is not yet finalised..)

This is my attempt and it has some problems.

 

Screenshot_2.png

 

re the filtering of "3000". the model has a date in year 3000 when the claim does not have a date finalised..

@amitchandak 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Based on your description, you can create a measure as follows.

Test table:

v-yuaj-msft_0-1608631441540.png

measure:

Measure = 

var x1=SELECTEDVALUE('DIM_Time'[DIM_FullDate])

return

IF(

DATEDIFF(SELECTEDVALUE('DIM_Time'[DIM_FullDate]),MAX('DIM_Claims'[Date_finalised]),YEAR)<=900,

IF(

x1<MAX('DIM_Claims'[Date_finalised])-MAX('DIM_Claims'[Date_Added]),

x1,

MAX('DIM_Claims'[DateFinalised])

),

x1-MAX('DIM_Claims'[Date_Added]))
 
Result:

v-yuaj-msft_1-1608631584669.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

 

Based on your description, you can create a measure as follows.

Test table:

v-yuaj-msft_0-1608631441540.png

measure:

Measure = 

var x1=SELECTEDVALUE('DIM_Time'[DIM_FullDate])

return

IF(

DATEDIFF(SELECTEDVALUE('DIM_Time'[DIM_FullDate]),MAX('DIM_Claims'[Date_finalised]),YEAR)<=900,

IF(

x1<MAX('DIM_Claims'[Date_finalised])-MAX('DIM_Claims'[Date_Added]),

x1,

MAX('DIM_Claims'[DateFinalised])

),

x1-MAX('DIM_Claims'[Date_Added]))
 
Result:

v-yuaj-msft_1-1608631584669.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Anonymous 

 

I dont get it. Please can you share the pbix for this if you still have it?

 

I am expecting a value representing amount of days in the measure result, but your screenshot shows a date..

 

If the datefinalised is 3000 01 01 (being unfinalised) then the days should be dateselected DIM Time Full Date minus DIM Claims Date Added

If the date is finalised (not 3000 01 01) and the date finalised is earlier than date selected then the days should be DIM Claims Date Finalised minus DIM Claims Date Added 
otherwise if the date finalised is (not 3000 01 01) and the date finalised is after the date selected then the days should be DIM Time Date Selected minus Date Added


just a reminder the Date selected DIM Time Full Date is on its own table (DIM Time) and Date Finalised and Date Added is another table DIM Claims.
also, there is only row per claim number and thus I dont have to calculate the latest Date Finalised etc

Anonymous
Not applicable

Hi @Anonymous ,

 

Can you share some sample data and the expected result to have a clear understanding of your question?

The information you have provided is not making the problem clear to me.

Can you please explain with an example?

 

Best Regards,

Yuna

 

Anonymous
Not applicable

Object: Measure that calculates the duration of a claim given a selected date in a slicer
If Claim finalised then Duration = Date Finalised or Date Selected if before Date Finalised minus Date Added
If Claim is not finalised then Duration = Date Selected minus Date Added

If no date selected, then current date should be used rather than Date Selected

 

Data set:

I have a DIM_Time table as my Calendar/Date Table which is the table to be used for Date Selected - "DIM_FullDate".
I have a DIM_Claims table which contains the claim details such as DateFinalised and DateAdded of the claim.
Where the Claim has not been finalised, the DateFinalised in DIM_Claims has been assigned a date in the far future...3000 eve, so I don't want that date to be used, but rather the Current Date or the Date Selected

 

I have started a measure that looks like this, but it is giving syntax errors. Not sure if it is because it is calculating over two tables..DIM_Claims and DIM_Time..

Screenshot_2.png

Anonymous
Not applicable

Hi @Anonymous ,

 

Sorry for that it's still not very clear. Can you share some sample data and the expected result to have a clear understanding of your question?

You can save your files in OneDrive, Google Drive, or any other cloud sharing platforms and share the link here.

 

Best Regards,

Yuna

Anonymous
Not applicable

Hi @Anonymous 

 

Unfortunately I can share my data set.

Anything else I can provide you with to help me?

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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