Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi people,
I am creating a content performance report. My company posts content on LinkedIn, and assigns a domain to each article. However, one article can have multiple domains. In the datafile I got from the Marketing department, both domains are listed seperately in 2 columns. I want to add the performance of all articles that share the same domain, for which I have to look at two columns.
So I have got a table that looks like this:
Post date | Domain 1 | Domain 2 | Views | Likes |
1-2-2022 | Work | 10 | 5 | |
1-3-2022 | Care | 13 | 6 | |
1-4-2022 | Living | Care | 14 | 9 |
1-5-2022 | Work | Care | 16 | 11 |
What I want to create is this:
Domain | Number of articles | Views | Likes |
Work | 2 | 26 | 16 |
Care | 3 | 43 | 26 |
Living | 1 | 14 | 9 |
I have no clue how to do this... I have looked into DISTINCT(UNION(VALUES..., GROUPBY, SUMMARIZE... Nothing seems to work and I am out of ideas.
Help would be very much appreciated! Thanks!
Solved! Go to Solution.
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
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!
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:
Thank you Alexis, this is the approach that works best!
What's the logic behind 'Living' getting 1 in the Number Of articles?
My mistake, there is no logic. I have been staring at these things for way too long 😂 Let me adjust my original post! Thanks for letting me know.
I thought this is the count of how many times was this category addressed?
In your example, Living exists once, Work twice and Care three times...
yes you are correct, I adjusted my mistake in my original post so you can disregard HotChilli's question 😊
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
115 | |
93 | |
86 | |
76 | |
64 |
User | Count |
---|---|
138 | |
113 | |
107 | |
98 | |
92 |