Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Den
Contributor II
Contributor II

Using Aggr to calculate percentage, excluding some values

My data looks like this:

DateMachineEvent_ClassDurationDuration_Percent
1/1/2020ABC123Downtime20 
1/1/2020ABC123Downtime15 
1/1/2020ABC123Uptime500.625
1/1/2020ABC123LowPerformance300.375
1/1/2020XYZ789Unrelated25 
1/1/2020XYZ789Uptime600.4
1/1/2020XYZ789LowPerformance200.133
1/1/2020XYZ789LowPerformance300.2
1/1/2020XYZ789Unavailable400.267
1/2/2020ABC123Unrelated15 
1/2/2020ABC123Uptime300.3
1/2/2020ABC123LowPerformance200.2
1/2/2020ABC123LowPerformance300.3
1/2/2020ABC123Unavailable100.1
1/2/2020ABC123Unavailable100.1

 

My end result is two different stacked bar graphs that will both be stacked by date and will only display if one machine is selected at a time (I got that part handled by the calculation condition).

The first graph works fine because it is just the sum of the duration of the events on a day, stacked by their "Event_Class":

Den_0-1588870582406.png

The second graph I'm having an issue with - I want to see the values of the "Event_Class" stacks in percentages instead of by the values, however, I want to exclude values where Event_Class = 'Downtime' or 'Unrelated' from the denominator of the percentage calculation so that the stacks will always be 100%. I worked around this by doing the percentage calculation of the events in the load script, however I have a new requirement that the user wants to be able to use the alternative dimension selector to change it from the date to the week, month, or year (so using my Duration_Percent column to average it over the amount of days won't work since that number is a percentage of that day's total duration of applicable Event_Class events. Below is what the intended output would look like:

Den_0-1588872891023.png

 

0 Replies