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
abadill
Resolver I
Resolver I

Post information from different columns

Hello good night,

Please someone who can help me with this consultation. In the following data management project information and each project has identified risks, which have been segmented into Risk Type 1, Risk Detail 1 and Risk Responsible 1. The same criterion applies when we want to record the 22 risk.

Question: How can I count these risks on a dashboard. How can I quantify the detail of those risks and their managers, since I handle several columns of information.

Best regards

Andrea

ProjectRISK TYPE 1RISK DETAIL 1RISK 1RISK TYPE 2RISK DETAIL 2RISK RISK 2
AAANOVEDAD_PREVENTAMISSING SIGNED CONTRACTWithNOVEDAD_PREVENTADESIGN-HLD NEWSC and D
BBBNOVEDAD_PLANIFICACIONDELAY IN CHRONOGRAM EXECUTIONPMOCAMBIOS_ALCANCECUSTOMER REQUESTS ADJUSTMENTS TO THE SCOPEWith
CCCNOVEDAD_DESPLIEGUEDELAY X JOBS/CIVIL WORK CUSTOMERClientNOVEDAD_COMPRASDELAY X LACK OF QUOTE/AFC and D
3 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hello

The data must be transformed as shown in the image below. This M code causes the transformation

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDBasNADER/Rew5Jd8ga2Vbye7KWa3tFBNCoYUGSk75f+ptSfGh1xnNzEPL4hDR7VzSiT3665B54lSqFMVMUgcmXWIPpKlkpLI68+3x+X/Gc71+6YOHxLOtCsHb/R28u+wW1zTNNhYwSSuEJJp+sgFfQRJQnzVplzECn5nG8usPUWsfxkbUrhgIE3FVRisaOUPm08hWDNAfVi2uTAZFofQMRjrwE72yENGGZeUegnA38h/IGQ7a2J5kkgCz5iM8h+rm1+3j/tgUkMYho23SAekI2sJp1MJ7bLe/uHwD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Project = _t, #"RISK TYPE 1" = _t, #"RISK DETAIL 1" = _t, #"RISK 1" = _t, #"RISK TYPE 2" = _t, #"RISK DETAIL 2" = _t, #"RISK 2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"RISK TYPE 1", type text}, {"RISK DETAIL 1", type text}, {"RISK 1", type text}, {"RISK TYPE 2", type text}, {"RISK DETAIL 2", type text}, {"RISK 2", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Project"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.1]), "Attribute.1", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Attribute.2"})
in
    #"Removed Columns"

I hope this helps.

Untitled.png


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

View solution in original post

Hello @abadill

Ashish_Mathur pbix file works well on my side, if you could use this way to open the file on the power bi desktop

File->Open->Browse, and then choose this file.

2.JPG

and for your requirement, you need to depivote and pivot your table in the energy query, here is the blog, please refer to it:

https://radacad.com/pivot-and-unpivot-with-power-bi

Best regards

Lin

Community Support Team _ Lin
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

Thank you if it worked for me.

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hello

The data must be transformed as shown in the image below. This M code causes the transformation

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDBasNADER/Rew5Jd8ga2Vbye7KWa3tFBNCoYUGSk75f+ptSfGh1xnNzEPL4hDR7VzSiT3665B54lSqFMVMUgcmXWIPpKlkpLI68+3x+X/Gc71+6YOHxLOtCsHb/R28u+wW1zTNNhYwSSuEJJp+sgFfQRJQnzVplzECn5nG8usPUWsfxkbUrhgIE3FVRisaOUPm08hWDNAfVi2uTAZFofQMRjrwE72yENGGZeUegnA38h/IGQ7a2J5kkgCz5iM8h+rm1+3j/tgUkMYho23SAekI2sJp1MJ7bLe/uHwD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Project = _t, #"RISK TYPE 1" = _t, #"RISK DETAIL 1" = _t, #"RISK 1" = _t, #"RISK TYPE 2" = _t, #"RISK DETAIL 2" = _t, #"RISK 2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"RISK TYPE 1", type text}, {"RISK DETAIL 1", type text}, {"RISK 1", type text}, {"RISK TYPE 2", type text}, {"RISK DETAIL 2", type text}, {"RISK 2", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Project"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.1]), "Attribute.1", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Attribute.2"})
in
    #"Removed Columns"

I hope this helps.

Untitled.png


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

Hello

The solution that you publish is exactly what I need but when I try to pass the code I get syntax errors. Please I can pass the file, I use powerbi in Spanish. I've been making several modifications but I don't find the solution. You can pass me to my email anbadi@uees.edu.ec or if I pass it over any link no problem.

Hi,

You may download my PBI file from here.

Hope this helps.


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

Hello

I can't open it when I open it since the winrar does not recognize it as a power bi file. What a pity, sorry the annoyance will be that I can sneak the step by step, how to make that change in the columns.

Thank you

Andrea.

Thank you if it worked for me.

Hello @abadill

Ashish_Mathur pbix file works well on my side, if you could use this way to open the file on the power bi desktop

File->Open->Browse, and then choose this file.

2.JPG

and for your requirement, you need to depivote and pivot your table in the energy query, here is the blog, please refer to it:

https://radacad.com/pivot-and-unpivot-with-power-bi

Best regards

Lin

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

Thank you if I could open the file and the solution if it worked for me.

Hi,

I really do not know how else to help you.  You should just be able to download the file and on double clicking it should open in PowerBI Desktop.  I am also attaching the file for your reference.


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

I get sintaxys error. This is what I'm placing. You can share the sample file for me.

• Table.TransformColumnTypes("Promoted Headers","PROJECT", type text, "RISK TYPE 1", type text, "RISK DETAIL 1", type text, "RISK 1", type text, "RISK TYPE 2", type text, "RISK DETAIL 2", type text,
"Changed Type" ? Table.TransformColumnTypes("Promoted Headers","PROJECT", type text, "RISK TYPE 1", type text, "RISK DETAIL 1", type text, "RISK", type text, "RISK TYPE 2", type text, "RISK DETAIL 2", type text, "RISK RISK 2", type text), . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "A" "QuoteStyle.Csv, true), "ATTRIBUTE.1", "ATTRIBUTE.2"-), "Changed Type1" - Table.TransformColumnTypes("Split Column by Delimiter","ATTRIBUTE.1", type text, "ATTRIBUTE.2", Int64.Type-),
"Pivoted Column" ? Table.Pivot("Changed Type1", List.Distinct("Changed Type1"[ATTRIBUTE.1]), "ATTRIBUTE.1", "VALUE"),
"Removed Columns" - Table.RemoveColumns("Pivoted Column","ATTRIBUTE.2"
in
"Removed Columns"

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.