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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Rajaganapathy
Frequent Visitor

Case age calculation

Hi,

I have date/time logging for different stages of the cases.

Like, First Response Provided, Under Investigation, Solution Provided, Pending customer Response, R&D, Resolved, and Closed.

I want to calculate the case age from the date the case is created.

While calculating the case age, the case age calculation should stop when the case status is changed to either of the following statuses - Pending Customer Response, R&D, or Resolved. For other case status, the case age calculation shall resume.

Rajaganapathy_0-1666182069525.png

I have a separate table that will log date/time changes in case status. I have another table in which the case created date/time is available. I have made a relationship between these tables.

Rajaganapathy_1-1666182201489.png

 

Please help me with the correct DAX formula. Thanks i

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Rajaganapathy ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a calculated column as below:

Case stage duration = 
VAR _predate =
    CALCULATE (
        MAX ( 'Table'[Timestamp] ),
        FILTER (
            'Table',
            'Table'[CaseNumber] = EARLIER ( 'Table'[CaseNumber] )
                && 'Table'[Timestamp] < EARLIER ( 'Table'[Timestamp] )
        )
    )
RETURN
    IF (
        'Table'[NewValue]
            IN {
            "Pending Customer Response",
            "R&D/Product Management",
            "Solution Implemented"
        },
        BLANK (),
        DATEDIFF ( _predate, 'Table'[Timestamp], DAY )
    )

yingyinr_2-1666249966310.png

 

In additon, you can refer the following links to get it:

Get durations from event data

Power BI: Tickets tracking

yingyinr_1-1666249429506.png

 

If the above ones can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
Rajaganapathy
Frequent Visitor

Thank you YingYinr - Thanks so much for your reply. Let me try this solution and come back.

v-yiruan-msft
Community Support
Community Support

Hi @Rajaganapathy ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a calculated column as below:

Case stage duration = 
VAR _predate =
    CALCULATE (
        MAX ( 'Table'[Timestamp] ),
        FILTER (
            'Table',
            'Table'[CaseNumber] = EARLIER ( 'Table'[CaseNumber] )
                && 'Table'[Timestamp] < EARLIER ( 'Table'[Timestamp] )
        )
    )
RETURN
    IF (
        'Table'[NewValue]
            IN {
            "Pending Customer Response",
            "R&D/Product Management",
            "Solution Implemented"
        },
        BLANK (),
        DATEDIFF ( _predate, 'Table'[Timestamp], DAY )
    )

yingyinr_2-1666249966310.png

 

In additon, you can refer the following links to get it:

Get durations from event data

Power BI: Tickets tracking

yingyinr_1-1666249429506.png

 

If the above ones can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Hi,

Thank you so much. I just did a little modification to the Formula you suggested.

Instead of "NewValue" - I have changed to "OldValue". I Want to ignore how many days the case stays in "Pending Response" or "R&D" or "Resolved" - when it moves to another state.

So I said the formula to ignore the days between any of the above states to the new stage.

Now I need your help to Ignore the weekend (Saturday & Sunday) from the calculation.

Please support.

Rajaganapathy_0-1666561721194.png

 

 

 

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors