Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
lemarcfj
Helper I
Helper I

Custom Grouping Calculations of Source/Medium from Google Analytics

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!

1 ACCEPTED SOLUTION
v-xjiin-msft
Solution Sage
Solution Sage

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.

View solution in original post

4 REPLIES 4
v-xjiin-msft
Solution Sage
Solution Sage

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. 

lemarcfj
Helper I
Helper I

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")

 

Capture.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.