Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nmck86
Post Patron
Post Patron

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

 

 

2020-02-19_14-07-27.jpg

1 ACCEPTED SOLUTION
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.

View solution in original post

1 REPLY 1
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.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.