Forum Discussion
power query transpose
- 6 years ago
I created a calculated table for you like this:
NewTable = VAR names = DISTINCT('Table'[Name]) RETURN ADDCOLUMNS( SELECTCOLUMNS(names, "Names", [Name]), "Age", CALCULATE(AVERAGE('Table'[Age]), FILTER('Table', 'Table'[Name] = [Names])), "Code1", IF(CONTAINS('Table', 'Table'[Name], [Names], 'Table'[Code], "AS"), "AS", BLANK()), "Code2", IF(CONTAINS('Table', 'Table'[Name], [Names], 'Table'[Code], "JA"), "JA", BLANK()) )If this doesn't work in your case, please explain in detail how PowerBI should know what value should be in Code1 and Code2 value.
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Anonymous ,
That's much more simple. Click on column Code1 and Code2, then click Transform-> Unpivot Columns. Remove and Attribute column and rename Value column with "Code". Then remove the blank value in the Code column using filter as below:
Finally, you will achieve the table.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey v-yuta-msft
I'm very sorry to say but you got it all wrong. The final solution that you've presented is what i have now, and what i want to transform. Could you please read my original/first message. You'll understand what i need...
Thank you so much for your effort
- JarroVGIT6 years agoResident Rockstar
I created a calculated table for you like this:
NewTable = VAR names = DISTINCT('Table'[Name]) RETURN ADDCOLUMNS( SELECTCOLUMNS(names, "Names", [Name]), "Age", CALCULATE(AVERAGE('Table'[Age]), FILTER('Table', 'Table'[Name] = [Names])), "Code1", IF(CONTAINS('Table', 'Table'[Name], [Names], 'Table'[Code], "AS"), "AS", BLANK()), "Code2", IF(CONTAINS('Table', 'Table'[Name], [Names], 'Table'[Code], "JA"), "JA", BLANK()) )If this doesn't work in your case, please explain in detail how PowerBI should know what value should be in Code1 and Code2 value.
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
- v-yuta-msft6 years agoCommunity Support
Anonymous ,
Hi, please see the previous solution I have post.
Regards,
Jimmy Tao