Forum Discussion

Thaysenclaes's avatar
Thaysenclaes
New Member
4 years ago
Solved

Dynamic reset running total

Hi all,  I Power BI rookie, and need your help for a DAX problem.   The case:   If a person over a 3 week period has more than 70.5 hour combined, then a bonus is paid. The same week can not b...
  • v-zhangti's avatar
    4 years ago

    Hi, Thaysenclaes 

     

    I simulated your data to make an example, I hope it will help you. Regarding your cumulative summation function can remain unchanged, you can use the IF function to determine that the last 2 weeks above 70.5 are not part of the reward range.

    Measure = 
    VAR Week1 =
        SUMX ( TOPN ( 3,
                SUMMARIZE (
                    FILTER ( ALL ( 'Table' ), [Week]<=MAX('Table'[Week] )),'Table'[Week],
                    "Sum", SUM ( 'Table'[Hours] )
                ), [Week], DESC  ),  [Sum] )
    VAR Week2 =
       SUMX ( TOPN ( 3,
                SUMMARIZE (
                    FILTER ( ALL ( 'Table' ), [Week]<=MAX('Table'[Week] )-1),'Table'[Week],
                    "Sum", SUM ( 'Table'[Hours] )
                ), [Week], DESC  ),  [Sum]  )
    VAR Week3 =
       SUMX ( TOPN ( 3,
                SUMMARIZE (
                    FILTER ( ALL ( 'Table' ), [Week]<=MAX('Table'[Week] )-2),'Table'[Week],
                    "Sum", SUM ( 'Table'[Hours] )
                ), [Week], DESC  ), [Sum]  )
    RETURN
        IF(Week1>70.5&&Week2>70.5&&Week3>70.5,0,IF(Week1>70.5&&Week2>70.5,0,IF(Week1>70.5,1,0)))

     

    Best Regards,

    Community Support Team _Charlotte

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