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
xandurr
Frequent Visitor

Change calculation of a column based on a slicer

I have a scenario im trying to do but i am struggling to work out how.
My colleague has done it in Tableau, and i dont want to admit that PowerBi cant do it, it must be able to and i just dont know how.

Image below, shows on the left, what the raw data looks like.

What i want to do, is have a display like the Table on the right hand side, where the column "Period 1 Qty Sold" is calculated only for the rows that are for the PromoPeriod that is selected on the first Slicer on the left.
Then i want the column "Period 2 Qty Sold" to be calculated only for the rows that are for the PromoPeriod that is selected on the second slicer on the right.

 

Is this possible?

 

Untitled.png

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

I think you'll need to duplicate the promo period column (lets call it PromoPeriod2)

 

Have slicer 1 as PromoPeriod and slicer 2 as PromoPeriod2

 

Promo 1 Qty Sold = CALCULATE(SUM(Tbl[QtySold]),ALLSELECTED(Tbl[PromoPeriod]))

Promo 2 Qty Sold = CALCULATE(SUM(Tbl[QtySold]),ALLSELECTED(Tbl[PromoPeriod2]))

 

I think you'll need to remove the slicer relationship from your table also.

View solution in original post

v-cherch-msft
Employee
Employee

Hi @xandurr

 

You may create two slicer tables use Slicer 1 = DISTINCT(Test[PromoPeriod]) first. Then you may create the measures as below to get the value as requested.

Period 1 Qty Sold =
CALCULATE (
    SUM ( Test[QtySold] ),
    FILTER ( Test, Test[PromoPeriod] IN VALUES ( 'Slicer 1'[PromoPeriod] ) )
)
Period 2 Qty Sold =
CALCULATE (
    SUM ( Test[QtySold] ),
    FILTER ( Test, Test[PromoPeriod] IN VALUES ( 'Slicer 2'[PromoPeriod] ) )
)

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
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-cherch-msft
Employee
Employee

Hi @xandurr

 

You may create two slicer tables use Slicer 1 = DISTINCT(Test[PromoPeriod]) first. Then you may create the measures as below to get the value as requested.

Period 1 Qty Sold =
CALCULATE (
    SUM ( Test[QtySold] ),
    FILTER ( Test, Test[PromoPeriod] IN VALUES ( 'Slicer 1'[PromoPeriod] ) )
)
Period 2 Qty Sold =
CALCULATE (
    SUM ( Test[QtySold] ),
    FILTER ( Test, Test[PromoPeriod] IN VALUES ( 'Slicer 2'[PromoPeriod] ) )
)

1.png

 

Regards,

Cherie

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

Thank you so much! Thats exactly what i needed!!!!!

Anonymous
Not applicable

I think you'll need to duplicate the promo period column (lets call it PromoPeriod2)

 

Have slicer 1 as PromoPeriod and slicer 2 as PromoPeriod2

 

Promo 1 Qty Sold = CALCULATE(SUM(Tbl[QtySold]),ALLSELECTED(Tbl[PromoPeriod]))

Promo 2 Qty Sold = CALCULATE(SUM(Tbl[QtySold]),ALLSELECTED(Tbl[PromoPeriod2]))

 

I think you'll need to remove the slicer relationship from your table also.

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.