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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Julie_
Frequent Visitor

How can I get the category that comes first

Hello,

 

I need a measure where I get the sum of duration for a category which comes first.

For example: 
I have a ticket system where the i have the ticket status: transmitted -> in process -> waiting for answer (when there is something unclear and the processor asks a question) -> solution

 

I need the sum of duration for either the ticket status "waiting for answer" or "solution", depending on wich category comes first.

I have also a column (Event_number), which sorts the ticketstatus.

 

Thanks!

1 ACCEPTED SOLUTION

hi @Julie_ 

supposing you have a table like:

case_idTicketStatusevent_numberactivity_duration
101101
1102102
1153103
1204104
1305105
1356106
1457107
201108
2102109
2153110
2354111
2305112
2206113
2457114

try to plot a measure like:

 

Measure = 
SUMX(
    VALUES(data[case_id]),
    CALCULATE(
        MINX(
            TOPN(
                1,
                FILTER(
                    data,
                    data[TicketStatus] IN {20, 35}
                ),
                data[event_number],
                ASC
            ),
            data[activity_duration]
        )
    )
)

 

it worked like:

FreemanZ_0-1683622284112.png

 

View solution in original post

6 REPLIES 6
FreemanZ
Super User
Super User

hi @Julie_ 

what sample data do you have?

Julie__0-1683620214146.png

Either sum the duration for Ticket Status 20 or 35, depending on which Ticket status comes first.

In that case i would need the cumulative sum up to TicketStatus 20, but I have to also sum it with all case_ids.

hi @Julie_ 

could you expand your sample data to include at least two ids?

Julie__0-1683621046433.png

the activity_duration is just the duration in milliseconds

hi @Julie_ 

supposing you have a table like:

case_idTicketStatusevent_numberactivity_duration
101101
1102102
1153103
1204104
1305105
1356106
1457107
201108
2102109
2153110
2354111
2305112
2206113
2457114

try to plot a measure like:

 

Measure = 
SUMX(
    VALUES(data[case_id]),
    CALCULATE(
        MINX(
            TOPN(
                1,
                FILTER(
                    data,
                    data[TicketStatus] IN {20, 35}
                ),
                data[event_number],
                ASC
            ),
            data[activity_duration]
        )
    )
)

 

it worked like:

FreemanZ_0-1683622284112.png

 

Julie__0-1683622943003.png

is there a possibility to just get the first of either ticket status 20 or 35?

and calculate then the cumulative sum till the first ticket status (20 or 35)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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