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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Anonymous
Not applicable

Conditional calculation with different unit of measure

Hi,

 

Can anyone help me achieve the below? 

 

I have these columns in PBi:

 

Case | Latest comment date | Case type 

1 | 03-18-2022 09:56:36 AM | A 

2 | 03-19-2022 15:35:23 PM | B 

3 | 03-21-2022 20:31:05 PM | C 

 

For case type A I would like to calculate how many hours have passed since the comment was placed till now.

For case type B and C I would like to calculate how many days have passed since the comment was placed till now.

 

My desired output is:
 

Case | Latest comment date | Case type | Passed

1 | 03-18-2022 09:56:36 AM | A |  80 hours

2 | 03-19-2022 15:35:23 PM | B | 2 days

3 | 03-20-2022 20:31:05 PM | C | 1 day

 

Appreciate your help!

 
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could add a calculated column as

Passed =
IF( 'Table'[Case type] = "A", DATEDIFF( 'Table'[Latest comment date], NOW(), HOUR) & " hours",
   DATEDIFF( 'Table'[Case type], NOW(), DAY) & " days"
)

or if you want to put it in a measure you would need to wrap the column references in SELECTEDVALUES functions

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you John!

johnt75
Super User
Super User

You could add a calculated column as

Passed =
IF( 'Table'[Case type] = "A", DATEDIFF( 'Table'[Latest comment date], NOW(), HOUR) & " hours",
   DATEDIFF( 'Table'[Case type], NOW(), DAY) & " days"
)

or if you want to put it in a measure you would need to wrap the column references in SELECTEDVALUES functions

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.