cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
xandurr Frequent Visitor
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

Accepted Solutions
jd009 Member
Member

Re: Change calculation of a column based on a slicer

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 Super Contributor
Super Contributor

Re: Change calculation of a column based on a slicer

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
jd009 Member
Member

Re: Change calculation of a column based on a slicer

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 Super Contributor
Super Contributor

Re: Change calculation of a column based on a slicer

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

xandurr Frequent Visitor
Frequent Visitor

Re: Change calculation of a column based on a slicer

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

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 374 members 3,291 guests
Please welcome our newest community members: