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
Anonymous
Not applicable

Slicer to switch between 2 columns

Hi,

I want to create a slicer to switch between 2 columms, which are displayed in the visuals. One column contains the invoice amount including taxes (21%), the other column contains the same invoices, but without taxes ((invoice amount / 121) * 100).

I have different visuals which must be updated when I filter between the two options (incl. tax, excl. tax).

Does anyone have an idea how to accomplish this? It seems rather simple, but I can't figure it out.

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous create another table with these two options and this table be not have relationship with anything, put column from this table as a slicer and use following dax to switch between values.

 

Change table name/column name in following dax as per your data model. Now you can use following "Amount" measure in your visuals and value will change based on option selected on the slicer.

 

Hope it is helpful

 

Amount = 
VAR __selectedSlicer = SELECTEDVALUE( NewTable[Slicer] )
RETURN
IF( __selectedSlicer = "Incl. Tax", SUM( Table[InclAmount] ), SUM( Table[ExclAmount] ) )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@Anonymous create another table with these two options and this table be not have relationship with anything, put column from this table as a slicer and use following dax to switch between values.

 

Change table name/column name in following dax as per your data model. Now you can use following "Amount" measure in your visuals and value will change based on option selected on the slicer.

 

Hope it is helpful

 

Amount = 
VAR __selectedSlicer = SELECTEDVALUE( NewTable[Slicer] )
RETURN
IF( __selectedSlicer = "Incl. Tax", SUM( Table[InclAmount] ), SUM( Table[ExclAmount] ) )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hello,

 

I am trying to replicate the same logic for my dashboard, however, it continuously defaults to the IF statement's 'fail' option.

 

I'm trying to do this for currency conversion, so I have a new table "Report Currency" with one column named "To_Currency" with 3 options, USD/EUR/CNY.

 

Additionally, I first created 3 LOOKUPVALUE statements for the report.  The report has sales data coming through in various currencies.  So I also have a Currency Exchange table with 'report currencies' in the rows and 'To_Currency" optiosn as the columns with the rates filled out.  These are confirmed to be working (named [USD Lookup] / [EUR Lookup] / [CNY Lookup]).

 

Again, no matter the currency selected in the slicer (To_Currency) it defaults to the CNY Lookup values, which come through correct.  But if "EUR" is selected in the slicer, it's still the "CNY" values populated.

 

Any idea on why this might be failing, or if there is some mistake in my formula above?

 

Best regards,

Alex

 

So my formula is:

Goal =
VAR __selectedSlicer = SELECTEDVALUE( 'Report Currency'[To_Currency] )
RETURN
IF( __selectedSlicer = "USD", 'Lessor/Lessee Schedule'[USD Lookup] , if( __selectedSlicer = "EUR", 'Lessor/Lessee Schedule'[EUR Lookup] , 'Lessor/Lessee Schedule'[CNY Lookup] ) )
Anonymous
Not applicable

Never mind my question...  but for other people's reference, the DAX needs to be a measure.  Perhaps that was obvious and I'm still too new to Power BI 🙂

@Anonymous In my reply, I mentioned Amount Measure but glad issue is resolved and that is the best way to learn. Cheers!!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thanks voor the quick reply, this worked exactly as I wanted. Much appreciated!

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.