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
itsmeanuj
Helper IV
Helper IV

Chart legends controlled by 2 different slicers

Hi Guys,

 

This is a unique problem (for me at least) that I want to solve.  There is a line chart visual whose legends need to be controlled by 2 different slicers. here is the snippet of the requirement. So the user wants to select a country (or countries) from the top slicer and cluster from the slicer on the right. e.g. User wants to select Belgium from the top dropdown which will show the line for Belgium. Now the user wants to select the value "Mid-Sized Market" from the right slicer and wants to see value for the Mid-sized market as well. The idea is to see how the individual country is performing vs the whole cluster. 

itsmeanuj_0-1704355876345.png

 

My data looks like this:

Month_numSalesCountryCluster
1100BelgiumMid Sized
1170FranceLarge Sized
1300United KingdomLarge Sized
1400JapanLarge Sized
1500GermanyLarge Sized
150SpainMid Sized
1150ItalyMid Sized
1180SwedenMid Sized
2120BelgiumMid Sized
2150FranceLarge Sized
2320United KingdomLarge Sized
2440JapanLarge Sized
24890GermanyLarge Sized
270SpainMid Sized
2110ItalyMid Sized
2190SwedenMid Sized
3110BelgiumMid Sized
3190FranceLarge Sized
3330United KingdomLarge Sized
3390JapanLarge Sized
3550GermanyLarge Sized
3100SpainMid Sized
3160ItalyMid Sized
3170SwedenMid Sized

 

if i can get any help on this that would be really apprecialble.

 

Thanks,
Anuj

 

 

1 ACCEPTED SOLUTION
v-junyant-msft
Community Support
Community Support

Hi @itsmeanuj ,

If I understand you correctly, you want to have a line for Belgium and another line for all countries for "Mid-Sized Market" by selecting two slicers. However after my test, according to your screenshot, you are applying country as a legend, but this has the limitation that you can't add another line in the line chart dedicated to "Mid-Sized Market" values.
So I find a workaround for you:

vjunyantmsft_0-1704439966150.png
I alse create a new table to create the slicer for Cluster:

vjunyantmsft_1-1704440033907.png

 

vjunyantmsft_2-1704440043190.png

And I use this DAX to create a new measure:

 Sales_Cluster = 
CALCULATE(
    SUM(Sheet2[Sales]),
    FILTER(
        ALL(Sheet2),
        'Sheet2'[Cluster] = SELECTEDVALUE('Table'[Cluster]) && 'Sheet2'[Month_num] = SELECTEDVALUE(Sheet2[Month_num])
    )
)

I then created the visual object as shown in the screenshot:

vjunyantmsft_3-1704440103531.png

The results are as follows:

vjunyantmsft_4-1704440203801.png


Best Regards,
Dino Tao
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

1 REPLY 1
v-junyant-msft
Community Support
Community Support

Hi @itsmeanuj ,

If I understand you correctly, you want to have a line for Belgium and another line for all countries for "Mid-Sized Market" by selecting two slicers. However after my test, according to your screenshot, you are applying country as a legend, but this has the limitation that you can't add another line in the line chart dedicated to "Mid-Sized Market" values.
So I find a workaround for you:

vjunyantmsft_0-1704439966150.png
I alse create a new table to create the slicer for Cluster:

vjunyantmsft_1-1704440033907.png

 

vjunyantmsft_2-1704440043190.png

And I use this DAX to create a new measure:

 Sales_Cluster = 
CALCULATE(
    SUM(Sheet2[Sales]),
    FILTER(
        ALL(Sheet2),
        'Sheet2'[Cluster] = SELECTEDVALUE('Table'[Cluster]) && 'Sheet2'[Month_num] = SELECTEDVALUE(Sheet2[Month_num])
    )
)

I then created the visual object as shown in the screenshot:

vjunyantmsft_3-1704440103531.png

The results are as follows:

vjunyantmsft_4-1704440203801.png


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

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.