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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
olimilo
Continued Contributor
Continued Contributor

Dynamic X, Y and Legend axis based on slicer?

I have 2 separate tables, connected 1:M via the Test # column. Is it possible to plot them in a single bar visual where the X, Y and Legend are based on the selected value of a Parameter Field? For example, if I select Test Name, it will show the data from the left visual, and if Component Name is selected, it will show the other one.

Sample PBIX: https://file.io/FBmHP0X5zTfV

 

olimilo_0-1729517183774.png

 

Test # Test Name Test Result
1 Test A01 PASS
2 Test A02 FAIL
3 Test A03 PASS
4 Test A04 PASS
5 Test A05 FAIL

 

Component #Test # Component NameComponent Result
1 1 Component APASS
2 1 Component BPASS
3 2 Component AFAIL
4 3 Component CPASS
5 3 Component HPASS
6 4 Component EPASS
7 4 Component FPASS
8 4 Component GPASS
9 5 Component AFAIL
10 5 Component BPASS
4 REPLIES 4
ajohnso2
Super User
Super User

test.pbix 

 

Take a look at the attached, pay attention to the model view as I have created a new table and changed relationships along with creating a new measure.

ajohnso2
Super User
Super User

 Field Parameters are your friend here, create a new field parameter and drop component and test field in, add a slicer, replace exisiting column axis with the resulting column from the field parameter as your visual axis

FieldParameter.gif

olimilo
Continued Contributor
Continued Contributor

The output doesn't seem correct. If you look at the component visual (top right), Component A and Component B do not match with what is shown in the visual with the field parameter. Again, these are coming from different tables. Most of the examples I see online are using the same table.

 

I tried creating a field parameter for the Axis, Legend and Value fields, but it doesn't seem to show the correct value when selecting the 2nd value (Component Name) in the slicer?

 

Field Parameters

(FP) Axis = 
{
    ("Test Name", NAMEOF('Test'[Test Name]), 0),
    ("Component Name", NAMEOF('Component'[Component Name]), 1)
}

(FP) Legend = {
    ("Test Result", NAMEOF('Test'[Test Result]), 0),
    ("Component Result", NAMEOF('Component'[Component Result]), 1)
}

(FP) Value = 
    {
        ("Tests", NAMEOF('Test'[Tests]), 0),
        ("Components", NAMEOF('Component'[Components]), 1)
    }

 

 

 

Measures

Tests = COUNTROWS('Test')
Components = COUNTROWS('Component')

 

 

olimilo_0-1729568824876.png

 

Visual not showing the correct values (Component Name selected in slicer):

 

olimilo_1-1729568853447.png

 

Hi @olimilo 

 

Did ajohnso2 's method solve your problem? If yes, could you please mark it as solution? This will help more users who are facing the same or similar difficulties. Thank you!

 

If you still have questions, please feel free to ask me.

 

Best Regards,
Yulia Xu

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.