March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Register NowGet certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I have a table, where I keep the start and end dates of Events and SubEvents. I assume, that Event starts when first SubEvent starts and ends when the last SubEvent ends.
There are gaps between SubEvents - they are not starting immediatelly one after another.
Now I want to make a pie chart of percentage duration of each SubEvent to total duration of Event. The chart should include idle time as separete category.
How to tackle with this one?
Thanks,
Joanna
Solved! Go to Solution.
Take a closer look at *.pbix file. "Idle" subevent is automatically added to each event in PowerQuery, so you don't need to it manually 😉
There are 2 important steps:
First we need to obtain this table in Power Query
Then you can use calculated column for the calculation of "idle" duration:
First we need to obtain total event time:
Duration of Event =
VAR _CurrentEvent = SELECTEDVALUE( Table_Events[Event] )
VAR _StartOfSelectedEvent =
MINX(
FILTER(
Table_Events,
Table_Events[Event] = _CurrentEvent
),
Table_Events[Start]
)
VAR _EndOfSelectedEvent =
MAXX(
FILTER(
Table_Events,
Table_Events[Event] = _CurrentEvent
),
Table_Events[End]
)
RETURN _EndOfSelectedEvent - _StartOfSelectedEvent
And then we can calculate duration of each of subevents:
Subevent Duration =
VAR _CurrentEvent = SELECTEDVALUE( Table_Events[Event] )
RETURN
IF(
Table_Events[Subevent] <> "Idle",
Table_Events[End] - Table_Events[Start],
Table_Events[Duration of Event] -
SUMX(
FILTER(
Table_Events,
Table_Events[Event] = _CurrentEvent
),
Table_Events[End] - Table_Events[Start]
)
)
I've uploaded a sample *.pbix file here. I'll keep it here for you for the next 20-30 days 🙂
It looks really promising - one question though. Is it any way around adding "Idle" subevent to every event? I have like hundreds of Events now and they are still coming so adding manually "Idle" is not a solution. ☹️
Take a closer look at *.pbix file. "Idle" subevent is automatically added to each event in PowerQuery, so you don't need to it manually 😉
I tried it and I can't find the piece of code where "Idle" is added to each event automatically 😓
I've copied your caclulations and nothing happened ☹️
Hi @Kohrinn, before copy-paste code from PowerQuery try to better understand it. I haven't seen your data, so you should first understand the proposed logic in that example, then compare the initial table with your and perfrom modificaitons step-by-step. To help you further I would need more details on what you've tried, what do you struggle with and sample of your raw data. Let me know if any help is needed!
Thank you! 😄
Hi @Kohrinn, you're on a right way! Try to replicate exactly same structure in PowerBI. Add "Duration" as a column of your dataset and then create a pie chart using "Event" and "Subevent" as legend items and "Duration" as values and format values as percentage. Let us know if you face any other issues (better if you can share your pbix in that case 😉 )
What about this "Time Idle" that I have to calculate and then somehow merge with the rest of SubEvents? This part is what I'm struggling with
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
78 | |
75 | |
58 | |
56 |
User | Count |
---|---|
131 | |
105 | |
96 | |
69 | |
66 |