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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
shubh25
Helper I
Helper I

Cumulative sum by dates (Even the missing dates)

Hi,

I am using measure to calculate profit across the dates.

2.png

This is the data that I am using. Date, Revenue on that date and Cumulative revenue.
Cumulative value even when I choose a particular filter comes correct as per the overall amount.
e.g.,2018 data.
1.png

 

But I would like to plot this on a clustered column chart so I need cumulative sum on all the days.

I use : 

Profit over period =
CALCULATE (
[Revenue],
FILTER (
ALL ( Financials ),
Financials[TxnDate] <= MAX ( Financials[TxnDate] )
&& Financials[Source.Name] = SELECTEDVALUE ( Financials[Source.Name] )))
 
I am getting this data 
3.png
However, I need this data in this form
4.png

I am getting these missing dates in 3rd picture because the overall table does not contain those dates.
Is there any measure or formulae that I can use to get the missing dates.

Please help.
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @shubh25 ,

 

One sample for your reference, please check the following steps as below.

1. Create a calendar table as below and make it related to the fact table.

CALENDAR = CALENDAR(DATE(2019,01,01),DATE(2019,01,31))

Capture.PNG

 

2. To create a measure.

Measure = CALCULATE(SUM('Table'[Revenue]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]<=MAX('CALENDAR'[Date])))

2.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

What is the difference between the 3rd and 4th Table?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-frfei-msft
Community Support
Community Support

Hi @shubh25 ,

 

One sample for your reference, please check the following steps as below.

1. Create a calendar table as below and make it related to the fact table.

CALENDAR = CALENDAR(DATE(2019,01,01),DATE(2019,01,31))

Capture.PNG

 

2. To create a measure.

Measure = CALCULATE(SUM('Table'[Revenue]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]<=MAX('CALENDAR'[Date])))

2.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

I am trying to do that already. However, rest of the filters are in another table i.e., "Finacials". Is there a way that I can use all and selectedvalue on columns from different tables. 
i.e., DATES from CALENDER & SOURCENAME from FINANCIALS.
The DAX expression I am currently using-

Profit over period =
CALCULATE (
[Revenue],
FILTER (
ALL ( Financials ),
Financials[TxnDate] <= MAX ( Financials[TxnDate] )
&& Financials[Source.Name] = SELECTEDVALUE ( Financials[Source.Name] )))
Greg_Deckler
Super User
Super User

I would use GENERATESERIES to create a new table with all of the dates you need, or just CALENDAR or CALENDARAUTO perhaps. Then you could use that as your axis.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Generating all dates for all the data set will create millions of rows which will slow down the pbix significantly.

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.