Forum Discussion

nmck86's avatar
nmck86
Post Patron
6 years ago
Solved

SWITCH FUNCTION OR IF HELP

I have a data set and I want when a state filter is not selected to show a column or measure with the pre_sales amount... when a state is selected I want it to show the total sales amount. Attaching the pbix file https://drive.google.com/file/d/12AGSNXyxrgZ8dQ2AqxCqGLqY9IQHN2eS/view?usp=sharing

and a screenshot below. Essentially i need the file to dynamically update depending on what filter I am using in the data

 

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi, you could create a new measure like this:

     

    Measure = IF(ISFILTERED([State]), SUM(Sheet1[Pre Sales]), SUM(Sheet1[Total Sales]))

     

    The problem is that it doesn't work when you have State in the same table since state is filtered on each row. That could be solved by creating a new colum that is a copy of State and use that one in the table or slicer instead of State. It's not the best solution, but it works.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, you could create a new measure like this:

     

    Measure = IF(ISFILTERED([State]), SUM(Sheet1[Pre Sales]), SUM(Sheet1[Total Sales]))

     

    The problem is that it doesn't work when you have State in the same table since state is filtered on each row. That could be solved by creating a new colum that is a copy of State and use that one in the table or slicer instead of State. It's not the best solution, but it works.