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.
Hello,
This is maybe a bit of a tricky one. I have a dataset which counts unique people aggregated by demographic and purchasing variables:
Age group | Sex | Apples | Orange | Pears | Peaches | Kiwi | N |
10-19 | Female | 1 | 0 | 1 | 0 | 0 | 32 |
20-29 | Male | 0 | 0 | 0 | 1 | 0 | 46 |
40-49 | Female | 1 | 1 | 1 | 0 | 0 | 7 |
20-29 | Female | 1 | 0 | 1 | 0 | 1 | 18 |
30-39 | Male | 0 | 1 | 1 | 0 | 1 | 33 |
(e.g. 32 females aged 10-19 purchased Apples and Pears).
I'd like to create a slicer where users can select multiple values for the listed fruits (Apples, Oranges, Pears, Peaches and Kiwi), then count the total number of unique people (N) who purchase at least one of the selected fruits. (e.g. rows 1,4,5 and 6 all purchased apples and/or kiwis, so if a user selects Apples and Kiwis, I will sum(n) on all those rows).
Most guides I've found have suggested unpivoting the data table, but if I do this it will cause aggregate groups that have more than one of the selected fruits to be duplicated in the rows, which will make my sums of [n] inaccurate.
Some other work arounds I've considered or attempted are:
I'm at a loss what to attempt next, and hoping someone has a good idea!
Solved! Go to Solution.
Hi @Anonymous ,
I would still unpivot my table but make sure that each row is counted only once. To do that, I'd craete an index column in the query editor prior to unpivoting as a unique reference to the original set of rows and then use the measure below
Unique Count =
SUMX ( SUMMARIZE ( 'Table', 'Table'[Index], 'Table'[N] ), [N] )
Please see attached pbix for the details
Proud to be a Super User!
Hi @Anonymous ,
As always, please post a sample data that can be copy-pasted to Excel as a table (not an image).
Proud to be a Super User!
Hi @danextian, apologies, I have changed the format of the table so that you should now be able to copy and paste it
Hi @Anonymous ,
I would still unpivot my table but make sure that each row is counted only once. To do that, I'd craete an index column in the query editor prior to unpivoting as a unique reference to the original set of rows and then use the measure below
Unique Count =
SUMX ( SUMMARIZE ( 'Table', 'Table'[Index], 'Table'[N] ), [N] )
Please see attached pbix for the details
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
101 | |
78 | |
70 | |
64 |
User | Count |
---|---|
140 | |
106 | |
100 | |
83 | |
73 |