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 everyone,
This is my first time posting to this forumn so please excuse any repitition or if I'm not following the rules.
I have a table that pulls in the source/medium from Google Analtyics. I'd like to use this dimension to create a custom calc/column in PowerBI that is based off of the rules I provide. When I was using Tableau at my previous job, this was an easy calculated field using the following syntax:
If Contains([source/medium], 'Facebook') OR Contains([source/medium], 'Instagram')
THEN "Social"
ELSEIF Contains([source/medium], "cpc")
Then "Paid Search"
END
..etc. This calc would create a new header, column, and dimension based off my rules and I could use it like any other dimension. I'm hoping that someone could help me create a similar calculated measure for PowerBI. I hate that I have to relearn calculation syntax, specifically DAX, but it is what it is. Has anyone else had to releard syntax from Tableau to BI? Any help/resources for this calculation and for making the transition would be greatly appreciated.
Thanks!
Solved! Go to Solution.
Hi @lemarcfj,
Try following expression with a calculated column:
Test = IF ( OR ( FIND ( "Facebook", [source/medium] ) > 0, FIND ( "Instagram", [source/medium] ) > 0 ), "Social", IF ( FIND ( "cpc", [source/medium] ) > 0, "Paid Search" ) )
If it doesn't satisfy your requirement, please share us some sample data and its corresponding expected result. So that we can make some proper tests.
Thanks,
Xi Jin.
Hi @lemarcfj,
Try following expression with a calculated column:
Test = IF ( OR ( FIND ( "Facebook", [source/medium] ) > 0, FIND ( "Instagram", [source/medium] ) > 0 ), "Social", IF ( FIND ( "cpc", [source/medium] ) > 0, "Paid Search" ) )
If it doesn't satisfy your requirement, please share us some sample data and its corresponding expected result. So that we can make some proper tests.
Thanks,
Xi Jin.
Thanks for your reply everyone. I actually ended up adding a Conditional Column where I was able to build IF/THEN logic using the build in function. Much appreciated for those who lent a hand.
Also, it looks like I can't use the Group feature because there are just too many source/medium combinations to manually select them all. I will need to be able to use "IF Contains" type of logic.
@lemarcfj : Instead of writing an IF Statement (which can be long), you can write the Switch Statement like this
=SWITCH('Table'[Source / Medium],"Insta","Social","FB","Social","YouT","Social","Orga","Organic","Dire","Organic","Paid","In-Organic")
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 |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |