I had a CSV file in the format like below,
Card Name | Sec Name | Question Text | Answer 1 | Answer 2 |
---|---|---|---|---|
Specialists Offline | Customer Satisfaction | Does the Bill | Yes | No |
Specialists Offline | Customer Satisfaction | Do Invoicing Term | Yes | No |
Specialists Offline | Customer Satisfaction | Have all appropriate Line | TRUE | FALSE |
To normalize the table in the below format
Card Name | Sec Name | Question Text | Answer |
---|---|---|---|
Specialists Offline | Customer Satisfaction | Does the Bill | Yes |
Specialists Offline | Customer Satisfaction | Does the Bill | No |
Specialists Offline | Customer Satisfaction | Do Invoicing Term | Yes |
Specialists Offline | Customer Satisfaction | Do Invoicing Term | No |
Specialists Offline | Customer Satisfaction | Have all appropriate Line | TRUE |
Specialists Offline | Customer Satisfaction | Have all appropriate Line | FALSE |
I used the query like below with the help of the experts, it works great
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Card Name", type text}, {"Sec Name", type text}, {"Question Text", type text}, {"Answer 1", type text}, {"Answer 2", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Card Name", "Sec Name", "Question Text"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Answer"}})
in
#"Renamed Columns"
But now the table format has changed that the each Answer has attributes associated with it like below
Sec Name | Question Text | Answer 1 | Answer 1 Score | Answer 2 | Answer 2 Score |
---|---|---|---|---|---|
Customer Satisfaction | Does the Bill | Yes | 10 | No | 0 |
Customer Satisfaction | Do Invoicing Term | Yes | 5 | No | 1 |
Customer Satisfaction | Have all appropriate Line | TRUE | 3 | FALSE | 0 |
Since each answers have scores associated with it , I need each row with Answers and Score
Sec Name | Question Text | Answer | Answer Score |
---|---|---|---|
Customer Satisfaction | Does the Bill | Yes | 10 |
Customer Satisfaction | Does the Bill | No | 0 |
Customer Satisfaction | Do Invoicing Term | Yes | 5 |
Customer Satisfaction | Do Invoicing Term | No | 1 |
Customer Satisfaction | Have all appropriate Line | TRUE | 3 |
Customer Satisfaction | Have all appropriate Line | FALSE | 0 |
So the answer record can be inserted with their scores associated that way it can be easily inserted in to Salesforce. I am very new to the Pivot queries any help is greatly appreciated