Forum Discussion

frankhofmans's avatar
frankhofmans
Icon for Helper IV rankHelper IV
5 years ago
Solved

Cumulative totals

hi all,

 

I want to create a cumulative table of the number of sickness cases and the duration of the cases. I have the following data table:

 

Employee IDAbsence in working days
1012
5193
1479
23112
4453
3624
915
1697
3775
2915

 

I want to create the following outcome:

 

Days of absence12345678910>10
# of cases013466778810
As % of total0%10%30%40%60%60%70%70%80%80%100%

 

I tried to find the solution in previous posts, but i couldn't find the exact answer.

 

Thanks in advance,

 

Regards, Frank

  • Hi frankhofmans 

     

    Plz let me know whether you'd like to get below one:

    Measure = var a = IF(ISBLANK(COUNTROWS(FILTER('Table',[Absence in working days]<=1))),0,COUNTROWS(FILTER('Table',[Absence in working days]<=1)))
    var b = COUNTROWS(FILTER('Table',[Absence in working days]<=2))
    var c = COUNTROWS(FILTER('Table',[Absence in working days]<=3))
    var d =  COUNTROWS(FILTER('Table',[Absence in working days]<=4))
    var e = COUNTROWS(FILTER('Table',[Absence in working days]<=5))
    var f = COUNTROWS(FILTER('Table',[Absence in working days]<=6))
    var g = COUNTROWS(FILTER('Table',[Absence in working days]<=7))
    var h = COUNTROWS(FILTER('Table',[Absence in working days]<=8))
    var i = COUNTROWS(FILTER('Table',[Absence in working days]<=9))
    var j = COUNTROWS(FILTER('Table',[Absence in working days]<=10))
    var k = COUNTROWS(FILTER('Table',[Absence in working days]>10||[Absence in working days]<=10))
    return SWITCH(TRUE(),MAX('Table2'[Days of absence])="1",a,MAX('Table2'[Days of absence])="2",b,MAX('Table2'[Days of absence])="3",c,MAX('Table2'[Days of absence])="4",d,MAX('Table2'[Days of absence])="5",e,MAX('Table2'[Days of absence])="6",f,MAX('Table2'[Days of absence])="7",g,MAX('Table2'[Days of absence])="8",h,MAX('Table2'[Days of absence])="9",i,MAX('Table2'[Days of absence])="10",j,k)
    Measure 2 = DIVIDE([Measure],MAXX(ALL(Table2),[Measure]))

    Pbix attached.

5 Replies

  • frankhofmans , if [Absence in working days] is the measure. Then it is the case of dynamic segmentation. You need to create a bucket table for Days of absence, and the use measure to deal with it.

     

    Please refer my video if that can help

    https://youtu.be/CuczXPj0N-k

     

    Or refer

    https://www.daxpatterns.com/dynamic-segmentation/
    https://www.daxpatterns.com/static-segmentation/
    https://www.poweredsolutions.co/2020/01/11/dax-vs-power-query-static-segmentation-in-power-bi-dax-power-query/
    https://radacad.com/grouping-and-binning-step-towards-better-data-visualization

    • frankhofmans's avatar
      frankhofmans
      Icon for Helper IV rankHelper IV

      hi,

       

      I can't replicate the correct dax formula from your Youtube video. Could you help me further with the needed formula(s)?

       

      Thanks in advance,

       

      Regards, Frank

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        frankhofmans , Try like

        Brand Bucket = divide(Countx(filter(VALUES('Table'[Employee ID]),[Absence in working days] >=Min('Days Bucket'[Start Limit]) && [Margin %] <max('Days Bucket'[End Limit])),'Table'[Employee ID]),calculate('Table'[Employee ID],allselected(Table)))

         

        Brand Bucket = divide(Countx(filter(VALUES('Table'[Employee ID]),[Absence in working days] >=Min('Days Bucket'[Start Limit]) && [Margin %] <max('Days Bucket'[End Limit])),'Table'[Employee ID]),calculate('Table'[Employee ID]))

         

        Bucket will 1-1, 1-2 till 10 and 10 -10000 <Big Number>

  • v-diye-msft's avatar
    v-diye-msft
    Icon for Community Support rankCommunity Support

    Hi frankhofmans 

     

    Plz let me know whether you'd like to get below one:

    Measure = var a = IF(ISBLANK(COUNTROWS(FILTER('Table',[Absence in working days]<=1))),0,COUNTROWS(FILTER('Table',[Absence in working days]<=1)))
    var b = COUNTROWS(FILTER('Table',[Absence in working days]<=2))
    var c = COUNTROWS(FILTER('Table',[Absence in working days]<=3))
    var d =  COUNTROWS(FILTER('Table',[Absence in working days]<=4))
    var e = COUNTROWS(FILTER('Table',[Absence in working days]<=5))
    var f = COUNTROWS(FILTER('Table',[Absence in working days]<=6))
    var g = COUNTROWS(FILTER('Table',[Absence in working days]<=7))
    var h = COUNTROWS(FILTER('Table',[Absence in working days]<=8))
    var i = COUNTROWS(FILTER('Table',[Absence in working days]<=9))
    var j = COUNTROWS(FILTER('Table',[Absence in working days]<=10))
    var k = COUNTROWS(FILTER('Table',[Absence in working days]>10||[Absence in working days]<=10))
    return SWITCH(TRUE(),MAX('Table2'[Days of absence])="1",a,MAX('Table2'[Days of absence])="2",b,MAX('Table2'[Days of absence])="3",c,MAX('Table2'[Days of absence])="4",d,MAX('Table2'[Days of absence])="5",e,MAX('Table2'[Days of absence])="6",f,MAX('Table2'[Days of absence])="7",g,MAX('Table2'[Days of absence])="8",h,MAX('Table2'[Days of absence])="9",i,MAX('Table2'[Days of absence])="10",j,k)
    Measure 2 = DIVIDE([Measure],MAXX(ALL(Table2),[Measure]))

    Pbix attached.