Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
davidwsw
Frequent Visitor

Cumulative sums

I have a table that tracks users' performance in various categories of questions as they take a quiz. 5 questions are drawn randomly from 3 different question categories X, Y and Z. A score is calculated for each user in each category based on how many correct answers he got in that category.

 

 

Question Categories.png

 

How can I calculate cumulative sums for CorrectAnswers and QuestionsAnswered by date, by user and by question category? I want to use the cumulative sums to caculate a cumulative score. That part is easy. It's the cumulative sums that I'm struggling with. This is the end result I'm looking for.

 

Cumulative.png

 

 

1 ACCEPTED SOLUTION

Hi @davidwsw,

 

Did the DAX in my orignal post meet your requirement?

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Sean
Community Champion
Community Champion

Do you want these as COLUMNS or MEASURES?

 

COLUMNS

 

Score = 'Table'[CorrectAnswers] / 'Table'[QuestionsAnswered]

CumulativeCorrectAnswers =
CALCULATE (
    SUM ( 'Table'[CorrectAnswers] ),
    ALLEXCEPT ( 'Table', 'Table'[User], 'Table'[QuestionCategory] ),
    'Table'[Date] <= EARLIER ( 'Table'[Date] )
)

CumulativeQuestionsAnswered =
CALCULATE (
    SUM ( 'Table'[QuestionsAnswered] ),
    ALLEXCEPT ( 'Table', 'Table'[User], 'Table'[QuestionCategory] ),
    'Table'[Date] <= EARLIER ( 'Table'[Date] )
)

CumulativeScore = 'Table'[CumulativeCorrecAnswers] / 'Table'[CumulativeQuestionsAnswered]
davidwsw
Frequent Visitor

@Sean Either as long as I can show them in a table visualization. Thanks.

Hi @davidwsw,

 

In your scenairo, you can create measures like below and drag them into the table visual:

 

CumulativeCorrectAnswers = CALCULATE(SUM( Sheet1[CorrectAnswers]),FILTER(ALL(Sheet1),Sheet1[Date]<=MAX(Sheet1[Date])),VALUES(Sheet1[User]), VALUES(Sheet1[QuestionCategory]))

 

CumulativeQuestionsAnswered = CALCULATE(SUM( Sheet1[QuestionsAnswered]),FILTER(ALL(Sheet1),Sheet1[Date]<=MAX(Sheet1[Date])),VALUES(Sheet1[User]), VALUES(Sheet1[QuestionCategory]))

 

CumulativeScore = CALCULATE(SUM( Sheet1[CorrectAnswers]),FILTER(ALL(Sheet1),Sheet1[Date]<=MAX(Sheet1[Date])),VALUES(Sheet1[User]), VALUES(Sheet1[QuestionCategory]))/CALCULATE(SUM( Sheet1[QuestionsAnswered]),FILTER(ALL(Sheet1),Sheet1[Date]<=MAX(Sheet1[Date])),VALUES(Sheet1[User]), VALUES(Sheet1[QuestionCategory]))

 

q1.PNG

 

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @davidwsw,

 

Did the DAX in my orignal post meet your requirement?

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.