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
vmonu
Helper II
Helper II

How to expand (or include) new column header dynamically in Power BI

Good day folks,

I have table that has rolling days coming from source.

As a result the header of the table got to change dynamically.

 

Unfortunately PBI is making me selecting the new day for it to show..

 

First day

----------

Example : Jan 1st  Jan 2   Jan 3..... Jan 31

Car                   1          2         3           33

Plane             5        10         20       25

 

Second day

------------

Example :   Jan 2   Jan 3..... Jan 31  Feb 1

Car                  2         3           33    0

Plane              10         20       25     5

 

Here is the Code that produces this output

 

Please note that I use Pivoted column has the data comes for Day 🙂 and i want to show it as a header...

 

let
Source = Sql.Database("xxxxx", "test"),
dbo_tmpView2 = Source{[Schema="dbo",Item="tmpView2"]}[Data],
#"Pivoted Column" = Table.Pivot(dbo_tmpView2, List.Distinct(dbo_tmpView2[Quarter]), "Quarter", "Cnt")

in
#"Pivoted Column"

 

I am thinking i should use ExpandedColumns but it's giving me error saying that the columnname has to be text (meaning hardcode).

 

Thanks

MN

5 REPLIES 5
v-chuncz-msft
Community Support
Community Support

@vmonu 

 

Instead of using Pivot Column in Query Editor, you may try Matrix visual.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Nope Matrix doesn't cut it... thanks @v-chuncz-msft 

 

All i am trying is simple

 

Jan   Feb....... Dec2019

 

Next month or later

 

Feb Mar .... Dec2019  Jan 2020 etc.,

 

 

Any other options

 

Thanks

MN

Ashish_Mathur
Super User
Super User

Hi,

See if my solution here helps - Append data from multiple worksheets of multiple workbooks where each worksheet has a different head....


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur  , i'M getting error (saying some image64 not valid etc.,) in the 3rd step ...and i am still not sure based on the video and blog that it will work.

 

You are trying to kind of merge 2 tables into 3rd one. 

 

I'm trying to just get the data and repopulate the header.

 

Can you just see/try based on my simple data sets i gave above

 

TIA

MN

I played with TableExpandTableColumn but i am getting this error

 

Expression.Error: The column 'Agerange,2017 Q2,2017 Q3,2017 Q4,2018 Q1,2018 Q2,2018 Q3,2018 Q4,2019 Q1,2019 Q2,2019 Q3,2019 Q4,' of the table wasn't found.
Details:
Agerange,2017 Q2,2017 Q3,2017 Q4,2018 Q1,2018 Q2,2018 Q3,2018 Q4,2019 Q1,2019 Q2,2019 Q3,2019 Q4,

 

Here is the row i added 

 

let
Source = Sql.Database("sqltest", "S_test"),
dbo_tmpView2 = Source{[Schema="dbo",Item="tmpView2"]}[Data],
#"Pivoted Column" = Table.Pivot(dbo_tmpView2, List.Distinct(dbo_tmpView2[Quarter]), "Quarter", "Cnt"),
#"Expanded Column"=Table.ExpandTableColumn(#"Pivoted Column", Lines.ToText(Table.ColumnNames(#"Pivoted Column"),","),List.Distinct(Table.ToList(#"Pivoted Column")))
in
#"Expanded Column"

 

 

--- This is the extra row i added

= Table.ExpandTableColumn(#"Pivoted Column", Lines.ToText(Table.ColumnNames(#"Pivoted Column"),","),List.Distinct(Table.ToList(#"Pivoted Column")))

 

Basically i was trying to show the new data i.e. not selected and showing automaitcally... Am i correct in this.

 

In other words , i don't want to select the new columns everytime (and that's what i am trying to do)

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.