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

Link entire column to a date

Hello everyone,

 

I have a table with a column for the name and a column for each month and I would like to get a stacked column chart with the sum of each month.

 

I'm able to get a chart but I don't know how to link each column to a date.

 

My exemple table :

 table.png

 

 Thank you in advance,

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @SGpowerbi,

 

You can transpose your table in Power query by these steps as the picture.

 

Capture.PNG

 

M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTTVU0lECYSMwHasDETWCihqiiBoDeQZ6plBxEAsmYwISM4ATCC2mEC6MMIBLmEHtBGMkk8yBfGM4jo0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, #"10/31/2018" = _t, #"11/30/2018" = _t, #"12/31/2018" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"10/31/2018", type number}, {"11/30/2018", Int64.Type}, {"12/31/2018", type number}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type1"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers",{{"Name", type date}, {"Name1", Int64.Type}, {"Name2", Int64.Type}, {"Name3", type number}, {"Name4", Int64.Type}, {"Name5", Int64.Type}, {"Name6", type number}, {"Name7", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type2",{{"Name", "Date"}})
in
    #"Renamed Columns"

Then you can create a date table and create relationship between them.

 

Table = CALENDARAUTO()

2.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @SGpowerbi,

 

You can transpose your table in Power query by these steps as the picture.

 

Capture.PNG

 

M code for your reference.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTTVU0lECYSMwHasDETWCihqiiBoDeQZ6plBxEAsmYwISM4ATCC2mEC6MMIBLmEHtBGMkk8yBfGM4jo0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, #"10/31/2018" = _t, #"11/30/2018" = _t, #"12/31/2018" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"10/31/2018", type number}, {"11/30/2018", Int64.Type}, {"12/31/2018", type number}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type1"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers",{{"Name", type date}, {"Name1", Int64.Type}, {"Name2", Int64.Type}, {"Name3", type number}, {"Name4", Int64.Type}, {"Name5", Int64.Type}, {"Name6", type number}, {"Name7", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type2",{{"Name", "Date"}})
in
    #"Renamed Columns"

Then you can create a date table and create relationship between them.

 

Table = CALENDARAUTO()

2.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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.