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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
stapelbr
Frequent Visitor

Add missing months of year per category (material number) in case the month of year is not present

Dear PowerBi Community,

I have tried for hours and hours and read to multiple threads but did not manage to solve this matter. What I would like is to have for each category (material number) at least one row with the month of year which is present in a calendar table (which is not in the query editor). This table is based upon the min and the max date present in the table with the contents.


Calendar table

stapelbr_0-1698865125275.png


Content table

stapelbr_1-1698865235344.png

 

So if a certain UIN has only several hits, e.g. only in januari 2024 and/or or november 2023 I would like to have additional rows for the months which are not present in the table. Hence for each unique material I would like to have always all months present like this:

stapelbr_2-1698865366407.png



Your expertise is really appreciated to get the query complete with missing months per category!

2 REPLIES 2
serpiva64
Super User
Super User

Hi,

i think you can o this way:

- first get your interval dates and transform it to a list

- then duplicate your principal table

- in the duplicated one maintain only a unique column of the material, add a column with the lists of dates, extract them to rows and finally merge this one with the original

You will get from this 

serpiva64_1-1698920679095.png

this that i think is your goal

 

serpiva64_0-1698920652452.png

 

 

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

Here you can copy the example

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUpPzdM1MgYygESsTrRSEpCZn1wCFTMBi4HUFafCxEzBYslAZm5iEUJvLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column2", type date}, {"Column3", Int64.Type}})
in
#"Changed Type"

Thanks Serpiva, spot on! The only issue I face now is that the new table created keeps waiting for the source to apply the changes made. It is waiting till eternity. The report contains already 390K rows of itself (without the additional months of years which were missing). 

Do you also have an idea to work around this?

Example: 

stapelbr_0-1698952930823.png

 

In my case:
"Waiting for SAP (3) ........"

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors