cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Shinigalo
Frequent Visitor

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 @Shinigalo 

 

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 @Shinigalo 

 

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

 

Appreciate your Kudos✌️!!

Hostidconfid
shinigalo@gmail.com122333
sivkya.loli@gmail.com122699
shinigalo@gmail.com123666
VahidDM
Community Champion
Community Champion

Hi @Shinigalo 

 

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

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!!

View solution in original post

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🙏

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.