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

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.

Reply
Anonymous
Not applicable

Visualizing multiple true/false questions in ONE stacked chart

Hi everybody

 

I'm new to Power BI and need some help visualizing multiple true/false questions in one chart as a percentage average of the sum sales prize. Here it goes:

Sales opportunity, unique#Sales prizeIs the car blue? Is the car a 4WDDoes the car have backseats?
11 $       100TrueFalseTrue
12 $       300FalseFalseTrue
13 $       250TrueTrueFalse
14 $       175TrueTrueFalse
15 $       100FalesFalseFalse

Is it possible to display/visualize the true/false data in ONE stacked bar chart, where you get a percentage view.

 

Example:

Sum sales prize is:  $925.

Percentage of cars that are blue: 60 %. Display: 60 % of sum sales price =$555

Percentage of cars that are 4WD: 40 %. Display: 40 % of sum sales price =$370

And so on... All in the same stacked bar chart.

 

I hope you're able to help.Thanks

BR

Anders

2 ACCEPTED SOLUTIONS
v-haibl-msft
Employee
Employee

@Anonymous

 

In this scenario, you can first transform your table in Query Editor and then you can get the expected result with one measure. Please refer to following steps.

  1. In Query Editor, duplicate Table1 and rename it to Table2.
  2. Delete the three columns (blue, 4WD and backseats) of Table1. Delete one column (Sales prize) of Table2.
    isualizing multiple truefalse questions in ONE stacked chart_1.jpg
  3. Multiple select the three columns (blue, 4WD and backseats) of Table2, click “Unpivot Columns”.
  4. Filter the rows which “Value” = True in Table2. Then delete the “Value” column.
    isualizing multiple truefalse questions in ONE stacked chart_2.jpg
  5. Select the “Attribute” column in Table2, click “Split Column by Delimiter” of Space at the right-most delimiter as below. Replace ? with null in “Attribute.2” column. Rename “Attribute.2” to “Type” and delete “Attribute.1” column.

    isualizing multiple truefalse questions in ONE stacked chart_3.jpg
  6. Close and apply Query Editor. A 1:* relationship between Table1 and Table2 will be created automatically. Create a measure with following formula. Set its Format to “Percentage”.
    Percent = 
    DIVIDE (
        SUM ( Table1[Sales prize] ),
        CALCULATE ( SUM ( Table1[Sales prize] ), ALL ( Table2 ) )
    )
  7. Drag Stacked bar chart into your canvas. Select Type for Axis, Percent for Value, Sales prize (Quick Calc Sum) for Tooltips.
    isualizing multiple truefalse questions in ONE stacked chart_4.jpg

View solution in original post

@Anonymous

 

After you update the data tables, you only need to click “Refresh All” in Query Editor.

isualizing multiple truefalse questions in ONE stacked chart_5.jpg

 

Best Regards,

Herbert

View solution in original post

5 REPLIES 5
v-haibl-msft
Employee
Employee

@Anonymous

 

In this scenario, you can first transform your table in Query Editor and then you can get the expected result with one measure. Please refer to following steps.

  1. In Query Editor, duplicate Table1 and rename it to Table2.
  2. Delete the three columns (blue, 4WD and backseats) of Table1. Delete one column (Sales prize) of Table2.
    isualizing multiple truefalse questions in ONE stacked chart_1.jpg
  3. Multiple select the three columns (blue, 4WD and backseats) of Table2, click “Unpivot Columns”.
  4. Filter the rows which “Value” = True in Table2. Then delete the “Value” column.
    isualizing multiple truefalse questions in ONE stacked chart_2.jpg
  5. Select the “Attribute” column in Table2, click “Split Column by Delimiter” of Space at the right-most delimiter as below. Replace ? with null in “Attribute.2” column. Rename “Attribute.2” to “Type” and delete “Attribute.1” column.

    isualizing multiple truefalse questions in ONE stacked chart_3.jpg
  6. Close and apply Query Editor. A 1:* relationship between Table1 and Table2 will be created automatically. Create a measure with following formula. Set its Format to “Percentage”.
    Percent = 
    DIVIDE (
        SUM ( Table1[Sales prize] ),
        CALCULATE ( SUM ( Table1[Sales prize] ), ALL ( Table2 ) )
    )
  7. Drag Stacked bar chart into your canvas. Select Type for Axis, Percent for Value, Sales prize (Quick Calc Sum) for Tooltips.
    isualizing multiple truefalse questions in ONE stacked chart_4.jpg
Anonymous
Not applicable

@v-haibl-msft

 

Thanks a lot, just what I needed! Seems like I have a lot "text editing" to do in the Query Editor, before I have the desired result.

 

Do you know if the table copying in the Query Editor is "remembered" or do I have to do this manually each time I update the data tables?

@Anonymous

 

After you update the data tables, you only need to click “Refresh All” in Query Editor.

isualizing multiple truefalse questions in ONE stacked chart_5.jpg

 

Best Regards,

Herbert

Anonymous
Not applicable

@v-haibl-msft

 

I will test to see if it works out. Thank you.

Anonymous
Not applicable

@v-haibl-msft

 

Thaks a lot! Just what I neeeded - quite a workaround though 🙂

 

Seems like I'm going to do a lot of "text-work" in the Query Editor, since the real table of course has a lot more content/questions. Do you know if the Query Editor is able to "remember" the copying of tables if I need to update theese numbers each month?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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