Search code examples
datasetqliksense

Pie chart of percentage of column over sum of columns


For the following dataset I want to create a pie chart in Qlik Sense. The dataset represents repairs within checks of aircraft and what tasknumbers these repairs have. I would like to see a pie chart of the tasks, to see what tasks occur the most (for instance: Task 1: 20%, task 2: 33%, etc). However, since I am new to Qlik Sense, I can't figure out how to get a pie chart using values from multiple columns. The complete dataset has about 130 tasks.

Aircraft    Check   Date        Task1   Task2   Task3   Task4   Task5
AAB         P1      01-01-10    4       0       4       3       0
AAC         P1      02-01-10    5       0       3       1       1
AAD         P2      03-01-10    5       1       1       0       1
AAE         P1      05-01-10    2       0       2       2       1
AAC         P3      05-01-10    2       0       5       0       1
AAB         P4      06-01-10    0       0       3       1       2
AAE         P2      08-01-10    3       0       0       4       1
AAD         P3      09-01-10    5       0       4       1       4
AAD         P4      10-01-10    4       2       0       4       4

I think the main problem is the dimension of the pie chart, since that consists of multiple columns but I am not sure. Does anybody know how to resolve such a problem?


Solution

  • One solution would be to unpivot/crosstable the data - which would create a table more like:

    Aircraft    Check   Date        Task   Value
    AAB         P1      01-01-10    Task1  4
    AAB         P1      01-01-10    Task2  0
    AAB         P1      01-01-10    Task3  4
    AAB         P1      01-01-10    Task4  3
    AAB         P1      01-01-10    Task5  0
    AAC         P1      02-01-10    Task1  5
    

    You could then do a sum(Value) with dimension as Task.

    In the script editor, assuming your table is called "Checks" this could be done with something like:

    Checks_new:
    crosstable(Task,Value,3)
    Load * resident Checks;
    drop table Checks;
    rename table Checks_new to Checks;
    

    A couple of other suggestions

    • Probably best not to do a pie chart if there are potentially 130 segments!
    • You could potentially exclude the zero values if they aren't required and if the data set gets big when you go from 1 row per aircraft/check/day to one row per aircraft/check/day/task