cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Add rows that they are missing and adding cumulative sum

Hei all,

I have a table similar this:

Rick_ferreira_0-1631812055974.png


However I need to buil using dax a table similar this:

Rick_ferreira_1-1631812103027.png


I need to add the rows with data is missing and after to add the column with sum cumulative.

Is it possible to build this?

Regards,



1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Try the below steps:

Step1,create date table and enter  product table:

Table2 = CALENDAR("2020,1,1","2020,1,5")

vluwangmsft_0-1632818539120.png

Step 2,crossjoin the two table:

Table4 = CROSSJOIN(Table2,Table3)

vluwangmsft_1-1632818576437.png

Step3,get the base table value:

value = CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[Date]=Table4[Date]&&'Table'[Product]=Table4[Product]))

Step 4,get the sum value the date<= earlier(date)

Column = CALCULATE(SUM(Table4[value]),FILTER(ALL(Table4),Table4[Product]=EARLIER(Table4[Product])&&Table4[Date]<=EARLIER(Table4[Date])))

Output result:

vluwangmsft_2-1632818665389.png

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Try the below steps:

Step1,create date table and enter  product table:

Table2 = CALENDAR("2020,1,1","2020,1,5")

vluwangmsft_0-1632818539120.png

Step 2,crossjoin the two table:

Table4 = CROSSJOIN(Table2,Table3)

vluwangmsft_1-1632818576437.png

Step3,get the base table value:

value = CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[Date]=Table4[Date]&&'Table'[Product]=Table4[Product]))

Step 4,get the sum value the date<= earlier(date)

Column = CALCULATE(SUM(Table4[value]),FILTER(ALL(Table4),Table4[Product]=EARLIER(Table4[Product])&&Table4[Date]<=EARLIER(Table4[Date])))

Output result:

vluwangmsft_2-1632818665389.png

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

amitchandak
Super User
Super User

@Anonymous , I think if you use a date table joined with date of your table. Also you need to use date from date table in visual

 

Cumm Sales = CALCULATE(SUM(Table[Values]),filter(allselected(date),date[date] <=max(date[Date])))

 

If needed add +0

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors