Forum Discussion
Creating table with categories from 2 columns in 1 column
- 4 years ago
Unpivoting as hashtag_pete suggests is a good idea but it does bring complications. One approach would be to do this unpivot in a separate table so that you have a Domains table like this:
and an Articles table like this:
And have them related like this:
Hello Anonymous ,
you need to go to Power Query and select the columns with the domains, in your example "Domain 1" and "Domain 2", then go to the Tab "Transform" and make "Unpivot Columns".
You can then for example delete the empty ones or load it all to Power BI Desktop, in order to do further calculations there.
If this helps, please give kudos and accept as solution.
Best
hashtag_pete
- Anonymous4 years agoNot applicable
Hi Pete,
Would that imply that I first have to duplicate the query? Because when I unpivot, those articles that have two domains show up as two different rows. For some other measures I have written DAX that for example averages the number of views:
Views(average) = AVERAGE(LinkedIn[Views])Since, after unpivoting, one article can show up in two rows, I guess those measures do not give me the correct value anymore, right? I could solve this by duplicating the query and doing your trick in that query. Or could you think of a better way? Thanks!
- AlexisOlson4 years ago
Super User
Unpivoting as hashtag_pete suggests is a good idea but it does bring complications. One approach would be to do this unpivot in a separate table so that you have a Domains table like this:
and an Articles table like this:
And have them related like this:
- Anonymous4 years agoNot applicable
Thank you Alexis, this is the approach that works best!