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.
I want to create a stacked bar chart by product of total cost ( = SUMX quantity * price). However, I have 3 price structures and I would like to have a slicer that would enable the user to select the price struture to see how it changes the total cost and by product. Do you have any advice on how to set this up? Thanks much.
Solved! Go to Solution.
HI, @Anonymous
There are two ways for you as reference:
1. In Edit Queries, select three price columns, then Unpivot columns
Then use Attribute column as a slicer and total measure=SUMX( Qty* Value)
2. Create a price table
then create three total cost measure
total cost A = SUMX(Table1,Table1[Qty]*Table1[PriceA]) total cost B = SUMX(Table1,Table1[Qty]*Table1[PriceB]) total cost C = SUMX(Table1,Table1[Qty]*Table1[PriceC])
and use Price from Price table as a slicer and use this formula as a total result
Measure selection = SWITCH(TRUE(), SELECTEDVALUE('Fact'[Price])="PriceA",[total cost A], SELECTEDVALUE('Fact'[Price])="PriceB",[total cost B], SELECTEDVALUE('Fact'[Price])="PriceC",[total cost C], BLANK())
Result:
and here is pbix file, please try it.
Best Regards,
Lin
HI, @Anonymous
There are two ways for you as reference:
1. In Edit Queries, select three price columns, then Unpivot columns
Then use Attribute column as a slicer and total measure=SUMX( Qty* Value)
2. Create a price table
then create three total cost measure
total cost A = SUMX(Table1,Table1[Qty]*Table1[PriceA]) total cost B = SUMX(Table1,Table1[Qty]*Table1[PriceB]) total cost C = SUMX(Table1,Table1[Qty]*Table1[PriceC])
and use Price from Price table as a slicer and use this formula as a total result
Measure selection = SWITCH(TRUE(), SELECTEDVALUE('Fact'[Price])="PriceA",[total cost A], SELECTEDVALUE('Fact'[Price])="PriceB",[total cost B], SELECTEDVALUE('Fact'[Price])="PriceC",[total cost C], BLANK())
Result:
and here is pbix file, please try it.
Best Regards,
Lin
Dear Lin, This is PERFECT! Thanks much.
I have 1 follow up question: I see in your sample file, Table1 (2) that "Qty" and "Value" are calculated. I would like to see formula/functions you used to create these. Is there any way to see those directly in the file. If not, could you please share the DAX formula? Thanks again.
Robert
hi, @Anonymous
This is Unpivot columns Function in Eidt Queries.
http://radacad.com/pivot-and-unpivot-with-power-bi
Click Home->Edit Queries into Power Query. and you will see the steps
Best Regards,
Lin
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 |
---|---|
112 | |
97 | |
83 | |
67 | |
61 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |