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
awalsh
Helper I
Helper I

Change Item Names In Legend from 2 Queries

Hi, 

 

I need to change the item names in the legend of this pie chart.

 

However, the items in the legend are coming from 2 different queries, making it difficult for me to change their name. (The yellow highlight is coming from NJ3002 Query, and the blue is coming from NJ2000 Query. 

 

Any suggestions on how to change the item names in the legend? 


Thank you in advance! 

 

awalsh_0-1623950934157.png

 

 

1 ACCEPTED SOLUTION

Hi, @awalsh ;

May be try to modify the measure as follows:

new =
VAR _relation =
    CALCULATE (
        MAX ( 'Table (2)'[Home] ),
        USERELATIONSHIP ( 'Table (2)'[ID], 'Table'[id] )
    )
RETURN
    IF (
        [Living]
            IN { "BH", "DD", "SA" }
            && _relation = "Home",
        [Living],
        _relation
    )

The final output is shown below:

vyalanwumsft_0-1624498011432.pngvyalanwumsft_1-1624498116211.png

Best Regards,
Community Support Team_ Yalan Wu
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

11 REPLIES 11
v-yalanwu-msft
Community Support
Community Support

Hi , @awalsh ;

You could create a column to concatenate these two columns , and you colud use this column as "Legend".

new = CALCULATE(MAX('Table'[Living]),USERELATIONSHIP('Table'[id],'Table (2)'[ID]))

The final output is shown below:

vyalanwumsft_0-1624428515852.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much for your help!!! This is definitely getting me closer to what I'm trying to do. 

 

There is just one thing - 

 

I added the column "new" (screenshot below) but the formula is marking the BH, DD, and SA as "Home" where I need them to say BH, DD and SA respectively. The rest of the values are appearing correctly in the "new column".

 

Is there a way to get these 3 items to show as BH, DD and SA instead of showing as "Home" while keeping the rest of the values in the new column the same? 

 

awalsh_0-1624456892611.png

Thank you again for your help!!! 

 

 

 

 

 

 

Hi, @awalsh ;

May be try to modify the measure as follows:

new =
VAR _relation =
    CALCULATE (
        MAX ( 'Table (2)'[Home] ),
        USERELATIONSHIP ( 'Table (2)'[ID], 'Table'[id] )
    )
RETURN
    IF (
        [Living]
            IN { "BH", "DD", "SA" }
            && _relation = "Home",
        [Living],
        _relation
    )

The final output is shown below:

vyalanwumsft_0-1624498011432.pngvyalanwumsft_1-1624498116211.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

THANK YOU SO MUCH! This is perfect!!!! 

parry2k
Super User
Super User

@awalsh how these tables are related? Maybe throw sample pbix file and share (remove sensitive information before sharing)



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I was able to relate the two tables by using a common field they share called "Member ID". Now that they are related, is there a DAX formula I could use to bring these two columns together into one? 

They're actually not related which is making matters more difficult. I would share a sample file but this file is riddled with PHI and HIPPA info - 

 

I was trying to figure out if there is a way for me to concatenate these two columns and then replace their values in the query editor or via an IF statement but I can't seem to find a way to concatenate them...

parry2k
Super User
Super User

@awalsh since you are using hierarchy in the pie chart, you need to add another column in your 2nd table with the value that you want to display and then use that in Pie chart. Basically whatever label you want to show you have to create a column for it.

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you for the quick response @parry2k . 

 

I get what you are saying but in the 2nd table there are only 3 different values in the legend (At Home, BH, DD and SA) the other values come from the first table (Home, Resource Home, Youth Detention Center, Resource Home, and Shelter).

 

My goal was to combine these using the hierarchy to get unique combinations identifying different populations.

 

 How would I rename these combinations only using the second table? 

 

 

awalsh
Helper I
Helper I

I want to rename each one completly so it is less confusing for the users. 

 

For example, the first one says "Home At Home" - I would like it to just say "Home"

The second one says "Home BH" - I would like to change this to "Behavioral Health" and so on for the rest of them. 

parry2k
Super User
Super User

@awalsh what you want to change it to? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.