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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
KristofferS
New Member

Dynamic Legend

I currently have a monthly trend clustered column chart that sorts the measured values by each calendar month. There are 2-4 column values for each month as they are "categories" put in the Legend of the visual. Within each category there is more sorting into "subcategories". I have a slicer that allows the user to choose a specific category, but I cannot figure out a way to show the subcategory when the category slicer is used. In essence, I am looking for a dynamic Legend that changes based from category to subcategory based on whether the slicer is used or not. If I design the visual with the subcategory as the Legend and the user chooses not to use the category slicer, the visual becomes a mess of hundreds of columns per month.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @KristofferS 

You can refer to the following solution.

Sample data

vxinruzhumsft_0-1691993413977.png

Then create a field paramater

vxinruzhumsft_1-1691993721472.png

 

Then put the paramater to the legend field

vxinruzhumsft_2-1691993757641.png

 

Then you can select the paramater to choose display cat/subcat legend

vxinruzhumsft_3-1691993821427.png

 

vxinruzhumsft_4-1691993828605.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
clewis
Helper I
Helper I

Hi There,

 

I watched this youtube video on dynamic legend which was very helpful, (https://www.youtube.com/watch?v=8e8a3o1w51M) but i'm stuck on the variable measure and getting an error saying "syntax for userrelationship is incorrect.  Here is my formula.....

 

Count of Unique Teammate Swipes (VARIABLE CATEGORY) =

SWITCH(

    True(),

    -----------------------ELT Category--------------------------

    SELECTEDVALUE('Legend Categories'[Field]) = "ELT Leader",

    CALCULATE(

        [Count of Unique Teammate Swipes]

        USERELATIONSHIP('Legend Categories'[Category], 'Teammate_WLI_Designation'[ELT Leader.])

    ),

 

    -----------------------WLI Designation--------------------------

    SELECTEDVALUE('Legend Categories'[Field]) = "Designation",

    CALCULATE(

        [Count of Unique Teammate Swipes]

        USERELATIONSHIP('Legend Categories'[Category], 'Teammate_WLI_Designation'[WLI Designation])

    ),

 

    -----------------------Work Location--------------------------

    SELECTEDVALUE('Legend Categories'[Field]) = "Work Location",

    CALCULATE(

        [Count of Unique Teammate Swipes]

        USERELATIONSHIP('Legend Categories'[Category], 'Teammate_WLI_Designation'[Work Location])

    ),

    BLANK()

)

 

 

 

I set up my legend category table as follows....

 

Legend Categories =

DISTINCT(Union(

    SELECTCOLUMNS(

        'Teammate_WLI_Designation',

        "Category", 'Teammate_WLI_Designation'[WLI Designation],

        "Field", "Designation"

    ),

    SELECTCOLUMNS(

        'Teammate_WLI_Designation',

        "Category", 'Teammate_WLI_Designation'[ELT Leader.],

        "Field", "ELT Leader"

    ),

    SELECTCOLUMNS(

        'Teammate_WLI_Designation',

        "Category", 'Teammate_WLI_Designation'[Work Location],

        "Field", "Work Location"

    )

))

 

 

All of my legend variables are coming off one table, so i created 3 inactive relationships from WLI_Integration_Designation table columns aligning as called out above to legend categories table [category].

 

Can anyone help me figure this out??  Thank you in advance!

Anonymous
Not applicable

Hi @KristofferS 

You can refer to the following solution.

Sample data

vxinruzhumsft_0-1691993413977.png

Then create a field paramater

vxinruzhumsft_1-1691993721472.png

 

Then put the paramater to the legend field

vxinruzhumsft_2-1691993757641.png

 

Then you can select the paramater to choose display cat/subcat legend

vxinruzhumsft_3-1691993821427.png

 

vxinruzhumsft_4-1691993828605.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.