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
PBIAnonymousPBI
New Member

How to create a custom 12 months sum column in power Query Editor

Hello All,


I have a file that i pull from the system for which i have the monthly consumption per month for each products in each column. Which means that everytime i receive a new extract a new column is added with the consumption of the month. 


I would like to make a custom column/calculation that would allow me to have the sum of the value for the past 12M and past 18M. 

 

I have heard that the indexing of the columns would be a good way to proceed but then i am stuck. 

 

Thank you for your help.

 

Kind regards

Tom Collin

1 REPLY 1
daXtreme
Solution Sage
Solution Sage

You should not store such data in a wide-format table but in a narrow-format table. So, each new entry should not create a new column because this is not how you handle such things in PBI, but it should add new rows. To make sure this is the case, use Power Query to mash up your data into the right format.

 

Your table should look something like:

ProdID | Month | Consumption

 

Not like this:

Consumption | Month | Prod1 | Prod2 | Prod3 |...

 

The above format is WRONG. Simple as that.

 

Once you've got the right table, it's easy to write the DAX you want. By the way, Month and Product should be extracted into their own dimensions and joined to the fact table that stores consumption. If you don't know what I'm talking about... please read this: Understand star schema and the importance for Power BI - Power BI | Microsoft Learn

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.