Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I have a table which contains SID, State and State Code. I want to create a column which shows the distinct count of state code for each state.
Example,
Data | ||
SID | State | State Code |
1 | Karnataka | KA |
2 | Tamilnadu | TN |
3 | Kerala | KL |
4 | Karnataka | KA |
5 | Tamilnadu | TNN |
6 | Delhi | DL |
7 | Tamilnadu | TNU |
8 | Kerala | KRL |
Expected Report | ||||
SID | State | State Code | Distictct Count | Comment |
1 | Karnataka | KA | 1 | 1 - KA |
2 | Tamilnadu | TN | 3 | 3 - TN, TNN and TNU |
3 | Kerala | KL | 2 | 2 -KL and KRL |
4 | Karnataka | KA | 1 | Only KA |
5 | Tamilnadu | TNN | 3 | 3 - TN, TNN and TNU |
6 | Delhi | DL | 1 | 1 - DL |
7 | Tamilnadu | TNU | 3 | 3 - TN, TNN and TNU |
8 | Kerala | KRL | 2 | 2 -KL and KRL |
Thanks in advance!
Solved! Go to Solution.
Hi , @vinothkumar1990
According to your description, you want to get the distincount of the [State Code] prt [State] .
[1]If you want to create a calcuated column, you can use this dax code:
Column = CALCULATE( DISTINCTCOUNT('Table'[State Code]) ,ALLEXCEPT('Table','Table'[State]) )
Column 2 = var _t = CALCULATETABLE( DISTINCT('Table'[State Code]) , ALLEXCEPT('Table','Table'[State]))
return
CONCATENATEX(_t , [State Code] , ",")
The result is as follows:
[2]If you want to create a measre , you can use this dax code and just put the field on the visual:
Measure = var _t = DISTINCT('Table'[State Code])
return
CONCATENATEX( _t , [State Code],",")
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , @vinothkumar1990
According to your description, you want to get the distincount of the [State Code] prt [State] .
[1]If you want to create a calcuated column, you can use this dax code:
Column = CALCULATE( DISTINCTCOUNT('Table'[State Code]) ,ALLEXCEPT('Table','Table'[State]) )
Column 2 = var _t = CALCULATETABLE( DISTINCT('Table'[State Code]) , ALLEXCEPT('Table','Table'[State]))
return
CONCATENATEX(_t , [State Code] , ",")
The result is as follows:
[2]If you want to create a measre , you can use this dax code and just put the field on the visual:
Measure = var _t = DISTINCT('Table'[State Code])
return
CONCATENATEX( _t , [State Code],",")
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
117 | |
84 | |
49 | |
38 | |
28 |
User | Count |
---|---|
188 | |
76 | |
73 | |
54 | |
42 |