Forum Discussion

cats_five's avatar
cats_five
Frequent Visitor
9 years ago
Solved

custom bins

I know this has been asked before, and the answer seemed to be no.  However that was a while ago...

 

With SLAs it's common that there are various targets to be hit - done on the due day, 2 days later, 5 days later 10 days later and so on.  I'd like to be able to colour a stacked bar chart accoding to whatever the SLA defines these numbers of days as.  Unfortunately they are almost never even.  This is an example I've done choosing the bin size myself, it's test data so a little cruddy but I think you can see what I want to do.  On this data there should be one bin for less than zero, another for zero, another for 1-3, another for 4-10 and the last one for over 10.

 

  • fhill's avatar
    fhill
    9 years ago

    This article seems to do what you want...  They were concerned about the order, but you can do the same thing to 'bypass' the Legend with your own custom Measures ordered correctly in the Values column...

     

    https://community.powerbi.com/t5/Desktop/Rearrange-Pies-in-Pie-Chart/m-p/25218#U25218

     

     

    Done Early = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] > 0))

    On Time = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] = 0))

    1-3 Days Late = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] < 0 && Table2[days_over_target] >= -3))

    4-10 Days Late = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] < -3 && Table2[days_over_target] >= -10))

    Over 10 Days Late = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] < -10 ))

     

     

5 Replies

  • fhill's avatar
    fhill
    Resident Rockstar

    Can you copy & paste some sample data please?

    • cats_five's avatar
      cats_five
      Frequent Visitor

      Here you go.

       

      visit_id,play_area_id,days_over_target
      2,2,-1
      734,2,-13
      3,3,1
      4,4,1
      7,7,-4
      9,9,-4
      15,15,-2
      763,15,-2
      16,16,0
      29,31,0
      528,31,-5
      30,32,1
      559,32,-5
      33,35,-1
      525,35,-5
      35,37,0
      545,37,-5
      36,38,0
      550,38,-5
      37,39,0
      511,39,-5
      38,40,0
      504,40,-5
      39,41,0
      505,41,-5
      40,42,0
      495,42,-5
      41,43,0
      497,43,-5
      43,46,-1
      598,46,-1
      1058,46,0
      1059,46,0
      50,53,-4
      1078,53,0
      51,54,-4
      1029,54,4
      52,55,-4
      1028,55,3
      56,59,-5
      57,61,-5
      1026,61,3
      1064,61,0
      1096,61,0
      1098,61,-1
      59,63,-5
      750,63,-2
      1070,63,-21
      60,64,-5
      62,66,-4
      766,66,-2
      63,67,-4
      1027,67,4
      68,73,-4
      70,75,-2
      1097,75,0
      1099,75,-42
      71,76,-2
      76,81,-2
      77,82,-2
      79,84,-2
      864,84,-3
      80,85,1
      1062,85,0
      1063,85,0
      82,88,2
      83,89,2
      86,94,2
      88,98,1
      89,99,1
      90,100,1
      93,103,0
      96,107,-1

      • fhill's avatar
        fhill
        Resident Rockstar

        This article seems to do what you want...  They were concerned about the order, but you can do the same thing to 'bypass' the Legend with your own custom Measures ordered correctly in the Values column...

         

        https://community.powerbi.com/t5/Desktop/Rearrange-Pies-in-Pie-Chart/m-p/25218#U25218

         

         

        Done Early = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] > 0))

        On Time = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] = 0))

        1-3 Days Late = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] < 0 && Table2[days_over_target] >= -3))

        4-10 Days Late = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] < -3 && Table2[days_over_target] >= -10))

        Over 10 Days Late = CALCULATE(COUNT(Table2[days_over_target]), FILTER(Table2,Table2[days_over_target] < -10 ))