cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
giorgiokatr Member
Member

sum different columns depending on a slicer selection

I have two tables

 

Date | MTD | QTD | YTD

 

second table is

Selection

MTD

QTD

YTD

 

slicer hav the values of second table

is there any other way than using if to have sum of MTD column of first table when MTD is selected etc?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: sum different columns depending on a slicer selection

Cool, 

 

Try this  it will help u, if not let me know.

1.JPG

 

 

 

Note : 

If u select multiple option it will move to Others part.

 

6 REPLIES 6
giorgiokatr Member
Member

Re: sum different columns depending on a slicer selection

think i found it

its switch...?

Super User
Super User

Re: sum different columns depending on a slicer selection

Cool, 

 

Try this  it will help u, if not let me know.

1.JPG

 

 

 

Note : 

If u select multiple option it will move to Others part.

 

giorgiokatr Member
Member

Re: sum different columns depending on a slicer selection

Cool @Baskar! So you create a var in order to avoid writing the if statement inside switch? Thanks!

Super User
Super User

Re: sum different columns depending on a slicer selection

Yes u r correct my friend. Var is more powerfull function in DAX.

 

It will help u in many situation, and good performance too.

 

:-)

giorgiokatr Member
Member

Re: sum different columns depending on a slicer selection

Thanks @Baskar! Can this var used in another measure? eg

 

SWITCH(Filter_Value,"MTD",SUM('MTD),"QTD",SUM(QTD),"YTD",SUM(YTD),"")
Super User
Super User

Re: sum different columns depending on a slicer selection

No, Var only used inside the measure , we can't use outside .

 

Cool