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
Anonymous
Not applicable

Production demand matrix automatic refresh

Hello Power BI community,

I am no expert on this, and I am working on a matrix that I would like to refresh daily thru the server. I have managed to build the matrix manually, but since the header fields will be changing every day, am I afraid the table won't be able to find the new fileds. Is there anyway to assign the columns dinamically based on some sort of criteria?

Please take a the below exmple, hope I explain my self.

Thank you very much!

 

CustomerPart NumberBacklogD 07/21/2020D 07/22/2020D 07/23/2020D 07/24/2020D 07/25/2020D 07/26/2020D 07/27/2020
Custormer XXXXX365773300000000
Custormer XXXXX786326437480000480480480480
Custormer XXXXX65369823400000000
Client ZZZZZ43232400060000000
Client ZZZZZ4234324240000000432
Client ZZZZZ123334560000302402592
Client ZZZZZ2354533230000000432
Client DDDDD32132317040000028800
Client DDDDD4255430000000180
Client DDDDD434325554080129602160021600
Client DDDDD5345366660000086400

 

Desired matrix

rit1ju_2-1595127735740.png

 

1 ACCEPTED SOLUTION

Hey @Anonymous ,

I assume the error is raised because one of the steps that are applied during the transformation is referencing the column name, that will no longer be present as time moves on. 

 

You have to be aware of the following setting:
File --> Options and settings --> Options --> Global --> Data load --> Type Detection
I have chosen "Never detect ..."
This choice prevents that Power Query will change data types automatically after specific transformation steps. When I'm done with basic transformations I manually change the data type.

For this reason, the following screenshots of the applied steps may look a little different. The following screenshot shows all the necessary steps:

TomMartens_0-1595173721943.png

Here is the M code, taken from the advanced editor:

let
    Source = Excel.Workbook(File.Contents("C:\Users\tmart\OneDrive\Desktop\DynamicDays.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Customer", "Part Number"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

As you can see, just the columns "Customer" and "Part Number" are referenced.
 

I assume that a step like "Change type" is responsible for raising the error as this step references columns by name. If a column is no longer available in the source file, this will raise an error.

I recommend that you remove all steps from your query, change the data type manually after you unpivoted the date columns.

 

Hopefully, this provides some ideas how to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

9 REPLIES 9
amitchandak
Super User
Super User

@Anonymous , If you are looking for Hybrid Table. It is not there. I have logged an idea for that. https://ideas.powerbi.com/ideas/idea/?ideaid=9bc32b23-1eb1-4e74-8b34-349887b37ebc

Hybrid.png

 

 

 

 

Anonymous
Not applicable

Hello Amitchandak,

I am not looking for a Hybrid table, the image you see right there is just a screenshot of the matrix and the actual query that I put together to show what I was doing. What I actually need is matrix with dinamic name columns.

Sorry if that created confusion.

Thanks,

TomMartens
Super User
Super User

Hey @Anonymous ,

 

it's necessary to create a sinigle column from all the columns that will form the column headers in your matrix.

Here are some screenshots how you can achieve this.

I'm starting with a table that looks like this:

TomMartens_0-1595130916138.png

In Power Query (the query editor) I mark the columns Customer and Part Number, from the context menu I choose "Unpivot Other Columns", choosing this command from the menu is important to consider the dynamic changes of the columns:

TomMartens_1-1595131148365.png

This will lead to a new table structure that looks like this (be aware that the screenshot just contains the 2 new columns):

TomMartens_2-1595131245365.png

Don't forget to rename the new columns attribute and value.

Now you can create a report using the Matrix visual that looks like this.

TomMartens_0-1595131628635.png

 

Whenever the dataset will refresh the new strucure of the source data will be considered using the transformation "Unpivot Other Columns".

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hello Tom,

First of all, thank you so much for taking the time to read my post.

I did all the steps as you instructed and the matrix structure is exactly what I was looking for. However, same as before, I get the error "The column 'D 07/24/2020' of the table wasn't found. " once that day no longer exist on the excel spreadsheet source. Also a new day will be added to the end table everyday.

Please let me know if I did something wrong, or if there's anything else that needs to be done.

Thanks again,

 
 

2020-07-18_23h19_50.png

 

 
 
 
 
 
 
 
 

 

 

 

 

 

 

 

 
 
 
 
 
 
 

 

 

 

 

 

 

 

Hey @Anonymous ,

 

can you please prepare to xlsx files that contain sample data.

Name one Day1 and the 2nd one Day2 (I'm aware that in real life the name of the will not change). Upload the files to onedrive, dropbox, or google drive and share the link.

 

Regards,

Tom 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi Tom,

Here you go, I hope there's solution.

https://drive.google.com/drive/folders/1-Jtpqw1XBenFvHvvVI_t1AtZ_O3TjwSC?usp=sharing

I really need to figure this out.

Thanks,

Hey @Anonymous ,

I assume the error is raised because one of the steps that are applied during the transformation is referencing the column name, that will no longer be present as time moves on. 

 

You have to be aware of the following setting:
File --> Options and settings --> Options --> Global --> Data load --> Type Detection
I have chosen "Never detect ..."
This choice prevents that Power Query will change data types automatically after specific transformation steps. When I'm done with basic transformations I manually change the data type.

For this reason, the following screenshots of the applied steps may look a little different. The following screenshot shows all the necessary steps:

TomMartens_0-1595173721943.png

Here is the M code, taken from the advanced editor:

let
    Source = Excel.Workbook(File.Contents("C:\Users\tmart\OneDrive\Desktop\DynamicDays.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Customer", "Part Number"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

As you can see, just the columns "Customer" and "Part Number" are referenced.
 

I assume that a step like "Change type" is responsible for raising the error as this step references columns by name. If a column is no longer available in the source file, this will raise an error.

I recommend that you remove all steps from your query, change the data type manually after you unpivoted the date columns.

 

Hopefully, this provides some ideas how to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Worked like magic !! I have been trying to figure this out on my own for quite a few days.

 

Thanks a lot!!

Hey @Anonymous ,

 

I'm happy it helped!

 

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.