cancel
Showing results for 
Search instead for 
Did you mean: 
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
VahidDM
Community Champion
Community Champion

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

VahidDM
Community Champion
Community Champion

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
Community Champion
Community Champion

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
VahidDM
Community Champion
Community Champion

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 ?

VahidDM
Community Champion
Community Champion

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

 

VahidDM
Community Champion
Community Champion

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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Top Solution Authors
Top Kudoed Authors