Forum Discussion

Dave2534's avatar
Dave2534
Regular Visitor
4 years ago
Solved

Grouping Values in Pie Chart

Hello, 

 

I have a pie chart that has a legend of employee names and counts the amount of shifts they have had in the last 14 days. 

 

I am looking to count and group the results into three categories of red, amber green.

 

When i've tried adding a calculated column to show results as red, amber or green I am struggling to get it to calculate the last 14 records.

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Dave2534 ,

    I created some data:

    Here are the steps you can follow:

    1. Create calculated column.

    Switch =
    SWITCH(
        TRUE(),
        'Table'[Count]>=0&&'Table'[Count]<=9,"Group1",
        'Table'[Count]>=10&&'Table'[Count]<=12,"Group2",
        'Table'[Count]>=13,"Group3")

    2. Set the color for the [Switch] column.

    3. Result:

    If you need pbix, please click here.

    Grouping Values in Pie Chart.pbix

     

    Best Regards,

    Liu Yang

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

3 Replies

  • onurbmiguel_'s avatar
    onurbmiguel_
    Power Participant

    Hello Dave2534

     

    So you need to catch the last 14 days and count the number of shifts? 

    Creat a calculated column in the employee table where you will pick the last 14 days with the function dateadd (https://docs.microsoft.com/en-us/dax/dateadd-function-dax) .

    if you have dificulty send a pbix example and i will try to help. 

     

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! ;-
    Best Regards
    BC

  • Dave2534's avatar
    Dave2534
    Regular Visitor

    Thank you for the assistance. 

     

    I've attached the pbix, i have used the dates in period function in a calculated column. I am aiming to get the pie chart to show 1 staff member red, 2 amber, 1 green. And for this to update upon refresh of new records.

     

    Sample 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Dave2534 ,

    I created some data:

    Here are the steps you can follow:

    1. Create calculated column.

    Switch =
    SWITCH(
        TRUE(),
        'Table'[Count]>=0&&'Table'[Count]<=9,"Group1",
        'Table'[Count]>=10&&'Table'[Count]<=12,"Group2",
        'Table'[Count]>=13,"Group3")

    2. Set the color for the [Switch] column.

    3. Result:

    If you need pbix, please click here.

    Grouping Values in Pie Chart.pbix

     

    Best Regards,

    Liu Yang

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