Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
lorenzoo
Regular Visitor

Calculated table working with slicers // Ordering matrix with different measures

Hi there everyone, 

 

I'm a beginner and I'm building my first dashboard. I'm analyzing questionnaire based data, stored on an excel file in this format: 

Respondent ID Country Social Media A Social media B Social media C Total
1 Country A        
2 Country B   Social media B   1
3 Country C Social Media A Social media B Social media C 1
4 Country B Social Media A     1
5 Country A      Social media C 1


I'm trying to build a visualization that shows how many people use a given social media, which slices based on nation. What I tried was at first to create a column equal to null if every Social media cell was empty, as per Respondent1, and equal to 1 if at least one social media cell showed a value. Then, i created three new different measures as follows:
Social media x measure= count [Social media x] / count [Total].
This allowed me to create a matrix where to put all the measures as values, that slice correctly but which I cannot order from highest to lowest: 

Social media A X%
Social media B Y%
Social media C  Z%


Alternatively I tried to create a calculated table where each row was written in DAX as follows: 
Table= {("social media A", Social media A measure), ("social media B", Social media B measure), ("social media C", Social media C measure)}. 
I now have another table which I can order at wish but does not update according to the nation slicer. How can I solve this problem and ultimately obtain a table that I can order and updates with slicers?

2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @lorenzoo,

 

Can you please try this:

 

1. Create a measure to calculate the percentage of responses for each platform:

Social Media Usage = 
DIVIDE(
    COUNTROWS('UnpivotedData'), 
    CALCULATE(COUNTROWS('UnpivotedData'), ALL('UnpivotedData'[Attribute]))
)

2. Create a rank measure based on the social media usage

Rank Social Media = 
RANKX(
    ALL('UnpivotedData'[Attribute]), 
    [Social Media Usage], 
    , DESC, Dense
)

Hope this helps!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

Anonymous
Not applicable

Hi @lorenzoo ,

 

@Sahir_Maharaj  provides a good solution. I still have some ideas here, I hope it will be helpful to you.


1. Enter Power Query Editor, hold down the Ctrl key to select the three columns as shown in the figure below, and select Unpivot Columns.

vkaiyuemsft_0-1710731093403.png

 

The obtained data is shown in the figure below.

vkaiyuemsft_1-1710731101293.png


2. Create Measure and write expressions. If the data that wants to be empty is not involved in calculation, you can add more conditions to the second parameter of the Filter function.

Measure =
Var _Cou1 = Calculete (Countries ('Table'), Filter (all ('table'), 'table' [value] <> black () && 'table' [value] = max ('table' [value]) && && 'Table' [country] = max ('table' [country])))
Var _Cou2 = Calculete (Countries ('Table'), Filter (all ('table'), 'table' [country] = max ('table' [country])))
Return
Divide (_Cou1, _Cou2)

3. If you want to sort the results, you can click the small triangle under the list to be raised or sorted.

vkaiyuemsft_2-1710731128660.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @lorenzoo ,

 

@Sahir_Maharaj  provides a good solution. I still have some ideas here, I hope it will be helpful to you.


1. Enter Power Query Editor, hold down the Ctrl key to select the three columns as shown in the figure below, and select Unpivot Columns.

vkaiyuemsft_0-1710731093403.png

 

The obtained data is shown in the figure below.

vkaiyuemsft_1-1710731101293.png


2. Create Measure and write expressions. If the data that wants to be empty is not involved in calculation, you can add more conditions to the second parameter of the Filter function.

Measure =
Var _Cou1 = Calculete (Countries ('Table'), Filter (all ('table'), 'table' [value] <> black () && 'table' [value] = max ('table' [value]) && && 'Table' [country] = max ('table' [country])))
Var _Cou2 = Calculete (Countries ('Table'), Filter (all ('table'), 'table' [country] = max ('table' [country])))
Return
Divide (_Cou1, _Cou2)

3. If you want to sort the results, you can click the small triangle under the list to be raised or sorted.

vkaiyuemsft_2-1710731128660.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Many thanks! That's the solution I was looking for 🙂 

Sahir_Maharaj
Super User
Super User

Hello @lorenzoo,

 

Can you please try this:

 

1. Create a measure to calculate the percentage of responses for each platform:

Social Media Usage = 
DIVIDE(
    COUNTROWS('UnpivotedData'), 
    CALCULATE(COUNTROWS('UnpivotedData'), ALL('UnpivotedData'[Attribute]))
)

2. Create a rank measure based on the social media usage

Rank Social Media = 
RANKX(
    ALL('UnpivotedData'[Attribute]), 
    [Social Media Usage], 
    , DESC, Dense
)

Hope this helps!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Many thanks! 😀

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors