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
viferenc
Helper II
Helper II

Use slicer to switch in one overview between Gross and Net amount

Dear All,

 

I would need your help for the following topic.

 

I have the a table:

 

Example.jpg

 

In this table i have two columns. 

 

But my goal would be to have only one column and I would like to change with the slicer what I would like to see, Gross or Net.

 

Thank you for your support.

 

BR

 

Feri

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @viferenc,

 

Create a table with the values:

 

Gross

Net

 

(I named the table and the column slicer but you can call what you want)

 

Add a slicer with the previous table and then in your sales table add this measure and add it to your visual:

 

Total_Sales = SWITCH(
		COUNT(Slicer[Slicer])=1,
		CONTAINS(Slicer,Slicer[Slicer],"Gross"),
			SUM(Sales[Gross]),
		CONTAINS(Slicer,Slicer[Slicer],"Net"),
			SUM(Sales[Net]),
		0)

What this does is count the number of values selected in the Slicer and if it's only one it selects the NET or Gross column if it's more than one it give you 0, if you want it to give always by default the Gross Sales for instance change it to:

 

Total_Sales = SWITCH(
		TRUE(),
		CONTAINS(Slicer,Slicer[Slicer],"Gross"),
			SUM(Sales[Gross]),
		CONTAINS(Slicer,Slicer[Slicer],"Net"),
			SUM(Sales[Net]),
		0)

Regards,

 

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @viferenc,

 

Create a table with the values:

 

Gross

Net

 

(I named the table and the column slicer but you can call what you want)

 

Add a slicer with the previous table and then in your sales table add this measure and add it to your visual:

 

Total_Sales = SWITCH(
		COUNT(Slicer[Slicer])=1,
		CONTAINS(Slicer,Slicer[Slicer],"Gross"),
			SUM(Sales[Gross]),
		CONTAINS(Slicer,Slicer[Slicer],"Net"),
			SUM(Sales[Net]),
		0)

What this does is count the number of values selected in the Slicer and if it's only one it selects the NET or Gross column if it's more than one it give you 0, if you want it to give always by default the Gross Sales for instance change it to:

 

Total_Sales = SWITCH(
		TRUE(),
		CONTAINS(Slicer,Slicer[Slicer],"Gross"),
			SUM(Sales[Gross]),
		CONTAINS(Slicer,Slicer[Slicer],"Net"),
			SUM(Sales[Net]),
		0)

Regards,

 

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hello - 

 

1. Am I supposed to create an actual data table in the "Data" module, or a table visualization in the "Report" module?

2. If the latter, how do I name a table visualization?

3. How do I name a slicer? 

4. Does this solution suffice if I am interested in Gross/Net views for more than just one field (i.e., not just Gross/Net Sales, but also maybe Gross/Net _____)?

 

Thanks!

Thank you very much

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.