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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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