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
giorgiokatr
Helper V
Helper V

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
Baskar
Resident Rockstar
Resident Rockstar

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.

 

View solution in original post

6 REPLIES 6
Baskar
Resident Rockstar
Resident Rockstar

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.

 

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

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

 

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

 

🙂

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

 

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

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

 

Cool

giorgiokatr
Helper V
Helper V

think i found it

its switch...?

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.

Top Solution Authors