Forum Discussion

v2's avatar
v2
Frequent Visitor
5 years ago
Solved

Cumulative calculation based on a Category

Hello,

 

I am completely lost as to how to achieve a cumulative calculation in Power Bi. I am assuming i will need a measure and not a calculated column?

 

I need to create two measures when a category is filtered.  The table1 below is a raw table and when filtered for CAT = "A" then the measures shoud result in cumulative values as table 2 so I can see on a line plot.

 

Thanks in advance.

 

Table 1

DateCATRateHours
11-08-21A0.5173.87
06-08-21A0.5583.58
01-08-21C0.4514.43
30-07-21D0.5743.48
23-07-21C0.5363.73
22-07-21E0.4414.53
10-07-21F0.414.88
03-07-21E0.82.5
01-07-21C0.4674.28
26-06-21B0.553.63
16-06-21A0.6742.97
13-06-21G0.4324.63
08-06-21F0.444.55
07-06-21G0.7232.77
03-06-21H0.414.88
27-05-21H0.5743.48
26-05-21J0.5713.5
24-05-21A0.3216.23
19-05-21B0.7692.6
18-05-21D0.5533.62
17-05-21C0.4434.52

 

Table 2

DateCATRateHoursMeasure1 = Cumulative RateMeasure 2 = Cumulative Hours
11-08-21A0.5173.870.5173.87
06-08-21A0.5583.581.0757.45
16-06-21A0.6742.971.74910.42
24-05-21A0.3216.232.0716.65
  • v2 , Create measures like

     

    calculate(sum(Table[Hour]), filter(allselected(Table), Table[category] = max( Table[category]) && Table[date] <= max( Table[date])))

     

     

     

    calculate(sum(Table[Rate]), filter(allselected(Table), Table[category] = max( Table[category]) && Table[date] <= max( Table[date])))

2 Replies

  • v2 , Create measures like

     

    calculate(sum(Table[Hour]), filter(allselected(Table), Table[category] = max( Table[category]) && Table[date] <= max( Table[date])))

     

     

     

    calculate(sum(Table[Rate]), filter(allselected(Table), Table[category] = max( Table[category]) && Table[date] <= max( Table[date])))

    • v2's avatar
      v2
      Frequent Visitor

      Thanks amitchandak.