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

How can I convert this table properly?

Hello!

My excel file look like this?

 

Skärmavbild 2020-08-30 kl. 17.51.07.png

What this data is telling you: April colomn, the numbers in that colomn is telling you 1th, 21th april etc...

 

This is how it go Transform > Unpivot Colums.  and then it looks like this,

Skärmavbild 2020-08-30 kl. 17.55.06.png

how can have ISIN in one colomn,
date in one,  
Countries in one?

1 ACCEPTED SOLUTION

Hi @Anonymous 

As 

Firstly I clean and transform the table : delete the text in Month column and replace the"*" as null.

Delete:

2.png

Replace:

3.png

Select all Month Columns and rightclick to replace.

6.png

Then Unpivote Month columns and Splite the Value column(Rename as Day column).

4.png

And Unpivote Country Columns as well. Finally,show the column not null in Day and Percent columns.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tVjBjuM2DP2VwEAuCx9EUqTEazHtYoEeFmi7QDvY//+NSrIcS7ak2DPZQJNkbEePj6TJR7+/T3/+Y5DFC6nBaZ7KhTAjh8/wQeGDlqMuHomXQjgu8TKbLzPm/vjtbbdXtX7O79Nfv5vwcqTAtDsf9oX4oaM9yutL4BolsANEcmLRxyvXH8xABdDC77hWZpmM9fczzCKmEU+gBj6Oad198+QZTMMsBGL00zwP35q2ZFhv0QiZz8Ay77a/TX3aEfZbyJ3fzPcfb19te+cNQjYoP1M0R8293r7mejugRZLErCoqiY48zh+YgjbJJqYzSnnsNnUzt8K2aMWjce7F2EPcdHcCEBDxFtjovTnhzmQWaPOldbOmsw9sghFcgzJbVO8w2bz99hrhGvRkOQpVguhZkBtl6SM8E6IFcSzPQvtKRFZBshkxxC9+cUfYXNIjclH3p3xHFehDzx7hUVRtjt8vJxxSiQyiilUeEtaN8SOr0gneiOcLCjssHcviqGzllhdexi8bBoNc2jO8Rc757kon/QxFIGaeb4Az+DLrC2/EHZDmbJ2pYjMKkU89rTDP+1BsVvP4gnlPrcumfekFcW8mS20agEMSbKQOVtmTg/xYK1xdBSs0lZ6AyE4B0kz088jlGksXJEBDDovemn7TC2YysWJ4psGEciDKqE9a6bW17r04z9gdg/p2j6bv0buCJP/j6F4fWqUXKBoOb23Ek37LaRH63Cg8bICDNPBNqHrTAisXD22Inj3RGo8sOJIgZRfX1ZUs2xD/xgVbGmJuVLUiUTCMXrEJXLPN2NrGvjYiRFHrNMhaYzpKoO3hQ3Paudj5flABnfdGVf1prh0/I16jyuE2wdAa+BLwcRLbt+Uz2MLGOgVv+ti50j+lfQ3YuJBcQe0NgFdYHcKqrb39/G6CUPTAk1+kELo5TYgFdta4qwlF+oXOWA4WLbGpblx3U18JiYYr964Ykrkvh1BK6Iqs6zaWLEOskZzkL4Aul3IPOc1t//54+4/I9ryTNm1mdm9+e5JjQWEbBxwmqIuQXGbE2SmcvWEC6zrtZzQRJ477PFqWxVEbspbYinT5fWRtDzKQkfzZRzEN2/ubExIr8HXhcWJzgKBjEVyvc8z9h1sxFEHJuelpXetneprbOYw6RNA1YJgJH4VFlhAyoTMJuJKeX8R6GWlRnWJrpC3EcpYir9TLS0WVoNRJp3XYy7KjO+DGCjebRvxrN9jyCdX2rd1otlk3VB2wrfL+C8eGpbqHGuR9b8qeRhP2oKWM51pxoLB4PvTOUw8W5qpk7Z3OUjv96O2W0w2rBYAX2qH+aEfThsoMZxTqe1sXQYH78Y22A609ZVj7RcJUgNC723VfZmCbSqCI+T7M2pTINTSFyc4R7YfTz0JPo6k1F3eKtAlh1crpuUdWcKeEa0M21703XsejuG+Cxt5iyekO5ZfWYfM3+ePv7+5sh2Q81KnIT+49jNinAI06Y3W6pv17LiyV79nHroTe5KJdZdJn62QL9ef/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ISIN = _t, Jan = _t, Feb = _t, Mars = _t, April = _t, Maj = _t, Juni = _t, Juli = _t, Aug = _t, Sept = _t, Okt = _t, Nov = _t, Dec = _t, USA = _t, Irland = _t, #"UK " = _t, #"Lu emburg" = _t, Asia = _t, Japan = _t, Europa = _t, Canada = _t, #"Latin America" = _t, Australia = _t, Africa = _t, Russia = _t, #"Me ico" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ISIN", type text}, {"Jan", type text}, {"Feb", type text}, {"Mars", type text}, {"April", type text}, {"Maj", type text}, {"Juni", type text}, {"Juli", type text}, {"Aug", type text}, {"Sept", type text}, {"Okt", type text}, {"Nov", type text}, {"Dec", type text}, {"USA", Percentage.Type}, {"Irland", type text}, {"UK ", Percentage.Type}, {"Lu emburg", type text}, {"Asia", Percentage.Type}, {"Japan", Percentage.Type}, {"Europa", Percentage.Type}, {"Canada", Percentage.Type}, {"Latin America", Percentage.Type}, {"Australia", type text}, {"Africa", type text}, {"Russia", Percentage.Type}, {"Me ico", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","*","",Replacer.ReplaceText,{"Jan", "Feb", "Mars", "April", "Maj", "Juni", "Juli", "Aug", "Sept", "Okt", "Nov", "Dec"}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Replaced Value", {"Dec", "Jan", "Feb", "Mars", "April", "Maj", "Juni", "Juli", "Aug", "Sept", "Okt", "Nov"}, "Attribute", "Value"),
    #"Unpivoted Only Selected Columns1" = Table.Unpivot(#"Unpivoted Only Selected Columns", {"USA", "Irland", "UK ", "Lu emburg", "Asia", "Japan", "Europa", "Canada", "Latin America", "Australia", "Africa", "Russia", "Me ico"}, "Attribute.1", "Value.1"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns1",{{"Attribute", "Month"}, {"Attribute.1", "Country"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Value.1", Percentage.Type}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type1", {{"Value", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Value"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Value", Int64.Type}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Changed Type2",{{"Value", "Day"}, {"Value.1", "Percent"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns1", each ([Day] <> null) and ([Percent] <> null))
in
    #"Filtered Rows"

 

Table:

1.png

And I build a Map visual:

5.png

If this reply still couldn't help you solve your problem, please show me more details about the result you want.

You can tell me what visual you want to build and show me a screenshot about the result, if you need to build a measure please show me your calculate logic.

You can download the pbix file from this link: How can I convert this table properly?

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

11 REPLIES 11
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

Greg_Deckler
Super User
Super User

@Anonymous - You are probably going to want to unpivot your groups of columns separately versus it looked like you did all of them. So, unpivot your month columns, split your day column by comman, unpivot those resulting columns, unpivot your country columns, etc. It is difficult to say exactly without sample data to test with:

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thank you! now it is super! 🙂 


How do if i want to have the location (in percente) to been shown in a map. i.e how much in percente are my proucts distributed? location; i guess that I will have all my countiers?

and then.. legend? latitude? longitude? tooltips?

@Anonymous Again, it is difficult to be specific without data to test with. But, if you have your countries unpivoted such that you end up with a Country column and a value column that holds the percent. Then you can categorize your country column as "Country" and then it will work great on a map visual.

Greg_Deckler_0-1598810998091.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  shall I upload it somewhere then instead? if you want to try?

@Anonymous - Yeah, upload it to like OneDrive or Box or something and post a link here.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Anonymous - Hmm, it is telling me that file doesn't exist for some reason when I click the link. I've tried with 2 different accounts.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Anonymous 

As 

Firstly I clean and transform the table : delete the text in Month column and replace the"*" as null.

Delete:

2.png

Replace:

3.png

Select all Month Columns and rightclick to replace.

6.png

Then Unpivote Month columns and Splite the Value column(Rename as Day column).

4.png

And Unpivote Country Columns as well. Finally,show the column not null in Day and Percent columns.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tVjBjuM2DP2VwEAuCx9EUqTEazHtYoEeFmi7QDvY//+NSrIcS7ak2DPZQJNkbEePj6TJR7+/T3/+Y5DFC6nBaZ7KhTAjh8/wQeGDlqMuHomXQjgu8TKbLzPm/vjtbbdXtX7O79Nfv5vwcqTA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3VB2wrfL+C8eGpbqHGuR9b8qeRhP2oKWM51pxoLB4PvTOUw8W5qpk7Z3OUjv96O2W0w2rBYAX2qH+aEfThsoMZxTqe1sXQYH78Y22A609ZVj7RcJUgNC723VfZmCbSqCI+T7M2pTINTSFyc4R7YfTz0JPo6k1F3eKtAlh1crpuUdWcKeEa0M21703XsejuG+Cxt5iyekO5ZfWYfM3+ePv7+5sh2Q81KnIT+49jNinAI06Y3W6pv17LiyV79nHroTe5KJdZdJn62QL9ef/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ISIN = _t, Jan = _t, Feb = _t, Mars = _t, April = _t, Maj = _t, Juni = _t, Juli = _t, Aug = _t, Sept = _t, Okt = _t, Nov = _t, Dec = _t, USA = _t, Irland = _t, #"UK " = _t, #"Lu emburg" = _t, Asia = _t, Japan = _t, Europa = _t, Canada = _t, #"Latin America" = _t, Australia = _t, Africa = _t, Russia = _t, #"Me ico" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ISIN", type text}, {"Jan", type text}, {"Feb", type text}, {"Mars", type text}, {"April", type text}, {"Maj", type text}, {"Juni", type text}, {"Juli", type text}, {"Aug", type text}, {"Sept", type text}, {"Okt", type text}, {"Nov", type text}, {"Dec", type text}, {"USA", Percentage.Type}, {"Irland", type text}, {"UK ", Percentage.Type}, {"Lu emburg", type text}, {"Asia", Percentage.Type}, {"Japan", Percentage.Type}, {"Europa", Percentage.Type}, {"Canada", Percentage.Type}, {"Latin America", Percentage.Type}, {"Australia", type text}, {"Africa", type text}, {"Russia", Percentage.Type}, {"Me ico", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","*","",Replacer.ReplaceText,{"Jan", "Feb", "Mars", "April", "Maj", "Juni", "Juli", "Aug", "Sept", "Okt", "Nov", "Dec"}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Replaced Value", {"Dec", "Jan", "Feb", "Mars", "April", "Maj", "Juni", "Juli", "Aug", "Sept", "Okt", "Nov"}, "Attribute", "Value"),
    #"Unpivoted Only Selected Columns1" = Table.Unpivot(#"Unpivoted Only Selected Columns", {"USA", "Irland", "UK ", "Lu emburg", "Asia", "Japan", "Europa", "Canada", "Latin America", "Australia", "Africa", "Russia", "Me ico"}, "Attribute.1", "Value.1"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns1",{{"Attribute", "Month"}, {"Attribute.1", "Country"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Value.1", Percentage.Type}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type1", {{"Value", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Value"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Value", Int64.Type}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Changed Type2",{{"Value", "Day"}, {"Value.1", "Percent"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns1", each ([Day] <> null) and ([Percent] <> null))
in
    #"Filtered Rows"

 

Table:

1.png

And I build a Map visual:

5.png

If this reply still couldn't help you solve your problem, please show me more details about the result you want.

You can tell me what visual you want to build and show me a screenshot about the result, if you need to build a measure please show me your calculate logic.

You can download the pbix file from this link: How can I convert this table properly?

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members 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.