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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mafaber
Helper II
Helper II

Cumulative for missing weeks

Hi,

 

I have a table containing demand per product in weekly buckets, I would like to calculate a cumulated demand for all weeks starting week00 to week53 (I have a scope of 1 year).

 

My issue is if there is no demand for a product on a certain week, when I do the cumulative calculation in Power Query, I only see cumulatives for weeks where there is demand. For product-week combinations that originally didn't exist in the table, because there was no demand on that week, cumulatives are missing (resulting in 0 when visualizing it).

I would like to see cumulatives for all weeks, what is the best practice to add the missing rows?

 

Data and calculations are quite heavy in the end, so it would be best avoiding mergeing and similar resource heavy calculations if possible.

 

mafaber_1-1675250327536.png

 

As you can see, cumulative calc is ok, but week01, wk03 and wk04 are missing.

3 REPLIES 3
ppm1
Solution Sage
Solution Sage

You can create a second query that lists all the week numbers and then merge your original query into that on the weeknumber column. You would then see all weeks (but have null values on the missing ones).

 

To get started, create a blank query with this as the first step. Then convert that to a table and merge in your existing query.

 

= List.Transform({1..53}, each "wk" & Text.PadStart(Text.From(_),2,"0"))

 

Pat

 

Microsoft Employee

I made it work. I had to create a supplementary table with all the existing products (remove other columns, remove duplicates), then added a calculated column with a list of weeks ({wk00, wk01, ..., wk52}) then expand it, so I had 53 rows per product, then I appended it to the original table, so all product-week combinations exist.

 

It's kind of unecessary amount of data and calculations, so if anyone has any better ideas, please share, but it works.

 

Thank you for the tip.

I tried this way, but the issue I got stuck with then is that I got all columns blank, not just the value. Since I have multiple products and the missing week could be first or last, I couldn't simply fill up or down.

mafaber_1-1675348083792.png

How do you deal with this?

 

Thank you!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors