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.
Hi All,
I'm working with social media data, and there is a string field that contains all used hashtags, in this format:
Table: Posts
Post | Hashtags used |
Post 1 | hashtag1 hashtag2 hashtag3 |
Post 2 | hashtag1 hashtag4 hashtag5 |
Post 3 | hashtag1 hashtag3 |
Post 4 | hashtag1 hashtag6 hashtag3 |
I was able to use power query to convert that into a single column list of all hashtags like so:
Table: dim_hashtag
Hashtag |
hashtag1 |
hashtag2 |
hashtag3 |
hashtag4 |
hashtag5 |
hashtag6 |
I want to be able to use dim_hastag as a filter in reports, but am unsure how to set up the joins.
Conceptually I think of it as joining dim_Hashtag to Posts, based on the string of dim_Hashtag appearing somewhere within the string of 'Hashtags used'. Is joining based on a partial string achievable?
Thanks for any advice!
Lucas
Solved! Go to Solution.
Hi @Braunnz ,
You could use CONTAINSSTRING() functions. Create a measure as below and add it to visual level filter.
https://docs.microsoft.com/en-us/dax/containsstring-function-dax
Measure = IF(CONTAINSSTRING(SELECTEDVALUE(posts[Hashtags used]),SELECTEDVALUE(dim_hashtag[Hashtag])),1,0)
Best Regards,
Jay
Hi @Braunnz ,
You could use CONTAINSSTRING() functions. Create a measure as below and add it to visual level filter.
https://docs.microsoft.com/en-us/dax/containsstring-function-dax
Measure = IF(CONTAINSSTRING(SELECTEDVALUE(posts[Hashtags used]),SELECTEDVALUE(dim_hashtag[Hashtag])),1,0)
Best Regards,
Jay
Hi @v-jayw-msft ,
My apologies for slow response, I got pulled away from this for a while. That method works perfectly, and opened my eyes to the application of measures as filters rather than just calculations.
Thanks very much!
@Braunnz You got it!
As a best practice and for a scalable solution, you always want to unpivot your data, instead of having pivoted data.
Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi again @parry2k ,
I think I'm almost there but missing something in how to set up the joins.
The way I set it up was to duplicate the posts query, and create an unpivoted table that's just Post ID and hashtag. I joined that table to Dim_hashtag by hashtag (one>many for dim>new), and to Posts by Post ID (one to many for Posts>New).
I'm guessing there's something off there since the hashtag field is not working as a filter for the pages I've set up based on fields / measures of the Post table.
Thanks so much for your advice!
@Braunnz you have split hashtag data into rows in your posts table too and then you can join these together.
Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k ,
Thanks for the reply! I'm not sure I follow what you're suggesting... are you saying to structure it so that each row in Posts would be duplicated by however many hashtags it has, then each duplicate row would have a single value for hashtag?
That makes sense to me, as I had considered a potential solution where I turn every single hashtag into a binary column, but I was hoping there might be a more elegant solution with partial string matches.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
95 | |
94 | |
79 | |
71 | |
64 |
User | Count |
---|---|
120 | |
105 | |
99 | |
81 | |
72 |