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.
Hi All
My data is as below:
StudentID | Name | City | Main Ethnicity | Ethnicity2 | Ethnicity3 |
1741262 | F | Wellington | European | Pasifika | Māori |
2085174 | H | Wellington | Māori | European | European |
1934579 | X | Wellington |
|
|
|
1274568 | E | Wellington | Māori | Pasifika | Pasifika |
2184074 | H | Wellington | Māori | Pasifika | Pasifika |
1061861 | D | Wellington | NZ European/Pakeha | European | European |
109241 | A | Wellington | NZ European/Pakeha | European | Pasifika |
109241 | A | Wellington | NZ European/Pakeha | European | Pasifika |
240739 | B | Wellington | NZ European/Pakeha | Māori | Other |
240739 | B | Wellington | NZ European/Pakeha | Māori | Other |
240739 | B | Wellington | NZ European/Pakeha | Māori | Other |
5859038 | K | Wellington | NZ European/Pakeha | Māori | Other |
1962443 | G | Wellington | NZ European/Pakeha | Māori | Pasifika |
2486795 | I | Wellington | NZ European/Pakeha | Pasifika | Pasifika |
2992062 | J | Wellington | NZ European/Pakeha | Pasifika | Pasifika |
2992062 | J | Wellington | NZ European/Pakeha | Pasifika | Pasifika |
423649 | Y | Wellington |
|
|
|
2992062 | J | Wellington | NZ European/Pakeha | Pasifika | Pasifika |
2992062 | J | Wellington | NZ European/Pakeha | Pasifika | Pasifika |
616474 | C | Wellington | Pasifika | NZ European/Pakeha | Chinese |
616474 | C | Wellington | Pasifika | NZ European/Pakeha | Chinese |
Out of this data, I wish to display a table having output as:
All Ethnicities | No. of Students | |
Chinese | 1 | |
European | 6 | |
Māori | 6 | |
NZ European/Pakeha | 8 | |
Other | 2 | |
Pasifika | 11 | |
Logic should be:
Is it possible in DAX?
Thanks
Solved! Go to Solution.
Hi Lin
Thank you so much for your solution and my apologies for such a late response.
Actually no one replied on my query for first few days so I left to pursue it and found a solution by myself,
which was interestingly almost similar to yours one, but I created 3 different tables(data sets) using SUMMARIZE and then created union of them in a final dataset.
Both of these solutions are serving the purpose partially, because, though they calculate the Total Count of students on all Ethnicities, but rest of the Dashboard is not filtered when I click on an individual Ethinicity (for example Chinese) in the table visual.
I solved this issue as below:
Redesigned the individual datasets, by creating Normalized datasets without duplication as it's the requirement to join two datasets in DAX data model.
Firstly created a granular dataset which is StudentID in this case, then another Dataset with StudentID and their Ethnicities,
and finally linked all datasets with StudentID using One-to-Many and Both directional filtering properties.
Now, the Count of StudentID is producing the totals and all the visuals are also being filtered mutually.
Thanks again
Kamran
HI,@kamran
After my research, You can do these follow my steps as below:
Step1:
use this formula to create a table
Group table =
var _table1=FILTER(SUMMARIZE('Table','Table'[Main Ethnicity],"No. of Students",DISTINCTCOUNT('Table'[StudentID])),'Table'[Main Ethnicity] <>BLANK()) return
var _table2=FILTER(SUMMARIZE('Table','Table'[Ethnicity2],"No. of Students",DISTINCTCOUNT('Table'[StudentID])),'Table'[Ethnicity2] <>BLANK()) return
var _table3=FILTER(SUMMARIZE('Table','Table'[Ethnicity3],"No. of Students",DISTINCTCOUNT('Table'[StudentID])),'Table'[Ethnicity3] <>BLANK()) return
var _uniontable=UNION(_table1,_table2,_table3) return
_uniontable
Step2:
Rename the column and drag fields into table visual
here is pbix, please try it.
Regards,
Lin
Hi Lin
Thank you so much for your solution and my apologies for such a late response.
Actually no one replied on my query for first few days so I left to pursue it and found a solution by myself,
which was interestingly almost similar to yours one, but I created 3 different tables(data sets) using SUMMARIZE and then created union of them in a final dataset.
Both of these solutions are serving the purpose partially, because, though they calculate the Total Count of students on all Ethnicities, but rest of the Dashboard is not filtered when I click on an individual Ethinicity (for example Chinese) in the table visual.
I solved this issue as below:
Redesigned the individual datasets, by creating Normalized datasets without duplication as it's the requirement to join two datasets in DAX data model.
Firstly created a granular dataset which is StudentID in this case, then another Dataset with StudentID and their Ethnicities,
and finally linked all datasets with StudentID using One-to-Many and Both directional filtering properties.
Now, the Count of StudentID is producing the totals and all the visuals are also being filtered mutually.
Thanks again
Kamran
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 |
---|---|
113 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |