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
Anonymous
Not applicable

create a pie chart wth calculated legend

Hello everyone ,

I have to display in pie chart the Number of hosts per number of conference bracket,

Fot that i do not have a legend and measure ,

 

legend should be displayed as this way ;

if count(conf id ) per host <4 ==>0-4 meetings

if count(conf id) per host between 4 and 10 ==> 4-10meetings

if count(confid) per host >10==> >10meetings

 

so in the legend i shouad have 3 items : 0-4 meetings    4-10meetings   10meetings 

 

and in the value of my pie chart i shuld have the number of host per number of the conference brackets

 

How can i do this please , i don't know how to create my legend

2 ACCEPTED SOLUTIONS

Hi @Anonymous 

 

Try to add a new column to your table with this code:

Count ID per Host =
VAR _Confid =
    FIRSTNONBLANK ( 'Table'[confid], "" )
VAR _Host =
    FIRSTNONBLANK ( 'Table'[Hostid], "" )
VAR _Count =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( ALL ( 'Table' ), 'Table'[Hostid] = _host && 'Table'[confid] = _Confid )
    )
RETURN
    SWITCH (
        TRUE (),
        _Count < 4, "0-4 meetings",
        _Count > 4
            || _Count < 10, "4-10 meetings",
        _Count > 10, "10 meetings"
    )

 

Then use that new column in your pie chart as a legend:

VahidDM_0-1631826925297.png

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

Appreciate your Kudos✌️!!

View solution in original post

In a Pie chart, I used the Hostid column and changed the aggregation to count.

Appreciate your Kudos!!

View solution in original post

8 REPLIES 8
VahidDM
Super User
Super User

Hi @Anonymous 

 

Can you share a sample of your data in a table format here:

 

Appreciate your Kudos✌️!!

Anonymous
Not applicable

Hostidconfid
shinigalo@gmail.com122333
sivkya.loli@gmail.com122699
shinigalo@gmail.com123666

Hi @Anonymous 

 

Try to add a new column to your table with this code:

Count ID per Host =
VAR _Confid =
    FIRSTNONBLANK ( 'Table'[confid], "" )
VAR _Host =
    FIRSTNONBLANK ( 'Table'[Hostid], "" )
VAR _Count =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( ALL ( 'Table' ), 'Table'[Hostid] = _host && 'Table'[confid] = _Confid )
    )
RETURN
    SWITCH (
        TRUE (),
        _Count < 4, "0-4 meetings",
        _Count > 4
            || _Count < 10, "4-10 meetings",
        _Count > 10, "10 meetings"
    )

 

Then use that new column in your pie chart as a legend:

VahidDM_0-1631826925297.png

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

Appreciate your Kudos✌️!!

Anonymous
Not applicable

what have you used for the value in your bar chart , is it a measure ?

In a Pie chart, I used the Hostid column and changed the aggregation to count.

Appreciate your Kudos!!

Anonymous
Not applicable

i do now have another problem

when i filter on period , the color of my title legend is changing

how can i fix this

Shinigalo_0-1632395066598.png

 

Try to fix set the colour manually first, then test it with filters:

VahidDM_0-1632433083620.png

 

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

Appreciate your Kudos🙏

Anonymous
Not applicable

I did it but the problem is that the color of my legend tilte change , how can i fix it

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.

Top Solution Authors