cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

## Can't calculate cumulative sum

Hi,

I'm trying to do the simplest calculation here. A have a table with a Date Key column and a colum "IsPayday", which is of Type Whole number.

I want to have a running total of the second one and have tried many variations of the formula below, but haven't figured it out:

Thanks for your help!

1 ACCEPTED SOLUTION
Super User

try

``````Is Payday running total =
VAR MaxDate =
MAX ( 'Calendar'[Datekey] )
VAR Result =
CALCULATE ( SUM ( 'Calendar'[Is payday] ), 'Calendar'[Datekey] <= MaxDate )
RETURN
Result
``````
4 REPLIES 4

Thank for your help.

I decided to change the source data and add ispayday as boolean in the data warehouse. With the field imported into Power BI I used the following variation of your code and got the calculation working:

``````Is Payday running total =
VAR MaxDate =
MAX ( 'Calendar'[Datekey] )
VAR Result =
CALCULATE(COUNTROWS('Calendar'), 'Calendar'[Datekey] <= MaxDate && 'Calendar'[ispayday] = true )
RETURN
Result``````

Super User

try

``````Is Payday running total =
VAR MaxDate =
MAX ( 'Calendar'[Datekey] )
VAR Result =
CALCULATE ( SUM ( 'Calendar'[Is payday] ), 'Calendar'[Datekey] <= MaxDate )
RETURN
Result
``````

Thanks for your help @johnt75

I tried it and have this error:

IsPayday is a custom column that I created in the Power Query Editor. Can that be the problem?

Super User

You have an extra ] after IsPayday

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors