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

scenario development with 3 price options

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. 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

HI, @Anonymous

There are two ways for you as reference:

1. In Edit Queries, select three price columns, then Unpivot columns

4.JPG5.JPG

Then use Attribute column as a slicer and total measure=SUMX( Qty* Value)

6.JPG

2. Create a price table

7.JPG

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:

8.JPG

 and here is pbix file, please try it.

 

 

Best Regards,

Lin

 

 

 

 

 

Community Support Team _ Lin
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

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

HI, @Anonymous

There are two ways for you as reference:

1. In Edit Queries, select three price columns, then Unpivot columns

4.JPG5.JPG

Then use Attribute column as a slicer and total measure=SUMX( Qty* Value)

6.JPG

2. Create a price table

7.JPG

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:

8.JPG

 and here is pbix file, please try it.

 

 

Best Regards,

Lin

 

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

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.

https://support.office.com/en-us/article/unpivot-columns-power-query-0f7bad4b-9ea1-49c1-9d95-f588221c7098

http://radacad.com/pivot-and-unpivot-with-power-bi

Click Home->Edit Queries into Power Query. and you will see the steps

11.JPG

 

12.JPG

 

 

Best Regards,

Lin

 

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

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.