Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I'm trying to create a cumulative sum of a measure over two dimensions and the measure has some missing values.
I have successfully created a simple cumulative sum over one dimension but with some missing values it fails.
The data:
Period | Partner | Category | Amount |
2021 Q1 | James | Payment | 12 |
2021 Q2 | James | Payment | 14 |
2021 Q4 | James | Payment | 23 |
2021 Q4 | James | Observation | 15 |
2022 Q2 | James | Payment | 8 |
2021 Q1 | Nelly | Payment | 8 |
2021 Q2 | Nelly | Payment | 15 |
2021 Q2 | Nelly | Observation | 23 |
2021 Q3 | Nelly | Payment | 62 |
2021 Q3 | Nelly | Observation | 45 |
2021 Q4 | Nelly | Payment | 15 |
2022 Q1 | Nelly | Payment | 48 |
2022 Q1 | Nelly | Observation | 45 |
2022 Q2 | Nelly | Payment | 12 |
2021 Q1 | Mark | Payment | 53 |
2021 Q1 | Mark | Observation | 74 |
2021 Q2 | Mark | Payment | 58 |
2021 Q2 | Mark | Observation | 55 |
2021 Q4 | Mark | Payment | 65 |
2021 Q4 | Mark | Observation | 23 |
2022 Q1 | Mark | Payment | 22 |
2022 Q1 | Mark | Observation | 56 |
2022 Q2 | Mark | Payment | 58 |
2022 Q2 | Mark | Observation | 45 |
The measure:
The chart by Period and Partner is wrong:
How can I create a measure which fills the blanks? I'd like to obtain the following:
Thanks a lot for the help!
Hi @16511151454 ,
I think the cause of the problem is that "James" has no record of "2021 Q3" in your metadata, which results in blank lines, and blank lines are not calculated. I recommend creating a new table and adding custom columns. Here is my method for your reference.
Custom table.
Table 2 = CROSSJOIN(VALUES('Table'[Period]),VALUES('Table'[Partner]))
Custom column.
Amount = CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Partner]=EARLIER('Table 2'[Partner])&&'Table'[Period]<=EARLIER('Table 2'[Period])&&'Table'[Category]="Payment"))
Best regards,
Mengmeng Li
As a best practice, add a date dimension in your model and use it for time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools. Check the related videos on my YT channel
Add Date Dimension
Importance of Date Dimension
Mark date dimension as a date table - why and how?
Time Intelligence Playlist
Having said that in DAX expression use the date column from the newly added date dimension and also to visualize the data, use the quarter column from the date table. It will fill in the missing period data.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Update your existing measure:
Cumulative Payment =
VAR CurrentPartner = SELECTEDVALUE('Table'[Partner])
VAR CurrentPeriod = MAX('Table'[Period])
RETURN
CALCULATE(
SUMX(
VALUES('Table'[Period]),
[Payment]
),
FILTER(
ALLSELECTED('Table'),
'Table'[Period] <= CurrentPeriod &&
'Table'[Partner] = CurrentPartner
)
)
You can create a total measure that sums across partners:
Total Cumulative Payment =
SUMX(
VALUES('Table'[Partner]),
[Cumulative Payment]
)
Thanks for looking into it.
Unfortunately it doesn't change the result.
I'm thinking there should be a way to dynamically create [Payment] values of 0 where it does not exist for a given combination of [Partner] and [Period]...
Hi,
Try this out (using Period as filtering):
Cumulative Payment =
CALCULATE(
sum(financials[ Sales]),
'calendar'[Month] <= SELECTEDVALUE('calendar'[Month])
)
Regards,
Oktay
If it helps, appreciate for Kudos and mark as solution 🙏🏻!!!
Thanks for the proposal but it does not work. Moreover SUM() cannot work on a measure and I do not have a table named 'calendar', neither can I create one.
On the table view, where you can view data, you csn create a calendar using the calendar(startdate, enddate).
The Start and end date would be min and max of your existing date field in the table. Therefore :
Calendar = calendar(min(Date), max(Date))
Afterwards, you can connect it in the modeling view.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
80 | |
76 | |
60 | |
36 | |
33 |
User | Count |
---|---|
91 | |
60 | |
59 | |
49 | |
45 |