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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Power BI switch Data in visuals through button

Hello there,

 

the question is really simple, yet for me as a beginner quite the opposite from simple.

 

I am currently studying Business Analyst Specialist and we have a task to switch visuals based on a button. But we are not supposed to use bookmarks but DAX to switch between the requested data.

 

For example, we need to add three buttons: Gross, Net, Profit

 

Each Button is supposed to switch between those values. I added a new table with all 3 names, but have no idea how to continue. I have set up a measure for each of the three options but I have no idea how to connect these through DAX.

 

anybody here that could help?

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Anonymous ,

@tharunkumarRTK Thanks for your reply!
Here is my sample data:

vjunyantmsft_0-1712722344322.png

I create three measures:

vjunyantmsft_1-1712722359379.png

Then use Field-parameter:

vjunyantmsft_2-1712722407253.png

vjunyantmsft_3-1712722434345.png

And put the parameter into the table visual:

vjunyantmsft_4-1712722495202.png

The final output is as below:

vjunyantmsft_5-1712722517117.png

vjunyantmsft_6-1712722522962.png

vjunyantmsft_7-1712722529322.png

Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Hello, thank you for your answers. So, both of your options work. But I did it this way:

 

Choices = IF ( SELECTEDVALUE(Choice[Button]) = "Gross", [Gross], IF(SELECTEDVALUE(Choice[Button]) = "Net", [Net], IF(SELECTEDVALUE(Choice[Button]) = "Profit", [Profit])))
 
This worked fine for me.
 
Now, I have another question.
 
I need to calculate values based on the year that is highlighted through a slicer. I need a formula that calculates the values of the last year based o nthe year that is selected. I did that through this:
 
Last_year_values =
VAR SelectedMetrik = SELECTEDVALUE(Choice[Button])
VAR CurrentYear = YEAR(MAX(Dates[Date]))
VAR LastYear = CurrentYear - 1
RETURN
CALCULATE (
SWITCH (
SelectedMetrik,
"Gross", [Gross],
"Net", [Net],
"Profit", [Profit]
),
FILTER ( ALL(Dates), YEAR(Dates[Date]) = LastYear )
)
 
That workes just fine. However, if I select a specific month of the current year, it is supposed to calculate last years values only for that selected month. But I fail in achieving this. Could you help me with that too? 🙂

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hello, thank you for your answers. So, both of your options work. But I did it this way:

 

Choices = IF ( SELECTEDVALUE(Choice[Button]) = "Gross", [Gross], IF(SELECTEDVALUE(Choice[Button]) = "Net", [Net], IF(SELECTEDVALUE(Choice[Button]) = "Profit", [Profit])))
 
This worked fine for me.
 
Now, I have another question.
 
I need to calculate values based on the year that is highlighted through a slicer. I need a formula that calculates the values of the last year based o nthe year that is selected. I did that through this:
 
Last_year_values =
VAR SelectedMetrik = SELECTEDVALUE(Choice[Button])
VAR CurrentYear = YEAR(MAX(Dates[Date]))
VAR LastYear = CurrentYear - 1
RETURN
CALCULATE (
SWITCH (
SelectedMetrik,
"Gross", [Gross],
"Net", [Net],
"Profit", [Profit]
),
FILTER ( ALL(Dates), YEAR(Dates[Date]) = LastYear )
)
 
That workes just fine. However, if I select a specific month of the current year, it is supposed to calculate last years values only for that selected month. But I fail in achieving this. Could you help me with that too? 🙂
Anonymous
Not applicable

Hi @Anonymous ,

@tharunkumarRTK Thanks for your reply!
Here is my sample data:

vjunyantmsft_0-1712722344322.png

I create three measures:

vjunyantmsft_1-1712722359379.png

Then use Field-parameter:

vjunyantmsft_2-1712722407253.png

vjunyantmsft_3-1712722434345.png

And put the parameter into the table visual:

vjunyantmsft_4-1712722495202.png

The final output is as below:

vjunyantmsft_5-1712722517117.png

vjunyantmsft_6-1712722522962.png

vjunyantmsft_7-1712722529322.png

Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.

tharunkumarRTK
Super User
Super User

@Anonymous 

Create three measures, Gross, Net and Profit and create Field parameter for switching the measure in the visual. 

You can refer this document for detailed explanation: https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters 


If the post helps please give a thumbs up


If it solves your issue, please accept it as the solution to help the other members find it more quickly.


Tharun



Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors