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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
UditJ
Helper III
Helper III

Datorama Calculations to Power BI

Is there a way we can replicate the below formula in power bi? 

IF( Site Name == 'DISCOVERY LATIN AMER', 'Discovery Channel Latin Amer',
IF( Media Buy Name contains 'P242V0D', 'Discovery Channel',
IF( Media Buy Name contains 'P2HD113', 'Hulu',
IF( Media Buy Name contains 'P2HKBPJ', 'YouTube Select',
IF( Media Buy Name contains 'P2HD112', 'Hulu',
IF( Media Buy Name contains 'ROKU', 'Roku', TJx-PARTNER [TJx-PARTNER]))))))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @UditJ ,

Based on the formula you've provided, it looks like you're attempting to categorize Site Names and Media Buy Names into different groups using a series of nested conditional statements. In Power BI, we can use the `SWITCH` function as an alternative to nested `IF` statements for better readability and maintenance. Here's how you can translate the provided formula:

Channel Name = 
SWITCH(
    TRUE(),
    'YourTable'[Site Name] = "DISCOVERY LATIN AMER", "Discovery Channel Latin Amer",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P242V0D"), "Discovery Channel",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P2HD113"), "Hulu",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P2HKBPJ"), "YouTube Select",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P2HD112"), "Hulu",
    CONTAINSSTRING('YourTable'[Media Buy Name], "ROKU"), "Roku",
    'YourTable'[TJx-PARTNER]
)

Please replace `'YourTable'` with the actual name of your table in Power BI.

 

Here's the step-by-step guide to implement this DAX formula:

1. Open Power BI Desktop and navigate to the Data view.
2. Select the table where you want to create the new calculated column.
3. Go to the Modeling tab and click on "New column".
4. Enter the DAX formula provided above into the formula bar.
5. Press Enter to create the column.

 

This formula uses the `SWITCH` function to evaluate each condition in turn and returns the corresponding channel name when a condition is met. The `CONTAINSSTRING` function is used to check if 'Media Buy Name' contains certain substrings.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @UditJ ,

Based on the formula you've provided, it looks like you're attempting to categorize Site Names and Media Buy Names into different groups using a series of nested conditional statements. In Power BI, we can use the `SWITCH` function as an alternative to nested `IF` statements for better readability and maintenance. Here's how you can translate the provided formula:

Channel Name = 
SWITCH(
    TRUE(),
    'YourTable'[Site Name] = "DISCOVERY LATIN AMER", "Discovery Channel Latin Amer",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P242V0D"), "Discovery Channel",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P2HD113"), "Hulu",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P2HKBPJ"), "YouTube Select",
    CONTAINSSTRING('YourTable'[Media Buy Name], "P2HD112"), "Hulu",
    CONTAINSSTRING('YourTable'[Media Buy Name], "ROKU"), "Roku",
    'YourTable'[TJx-PARTNER]
)

Please replace `'YourTable'` with the actual name of your table in Power BI.

 

Here's the step-by-step guide to implement this DAX formula:

1. Open Power BI Desktop and navigate to the Data view.
2. Select the table where you want to create the new calculated column.
3. Go to the Modeling tab and click on "New column".
4. Enter the DAX formula provided above into the formula bar.
5. Press Enter to create the column.

 

This formula uses the `SWITCH` function to evaluate each condition in turn and returns the corresponding channel name when a condition is met. The `CONTAINSSTRING` function is used to check if 'Media Buy Name' contains certain substrings.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

zenisekd
Super User
Super User

Hi, use simple

IF('table'[column name] = "text" , "true statement", "false statement")
https://learn.microsoft.com/en-us/dax/if-function-dax



together with statement CONTAINS(table,column, "statement")
https://learn.microsoft.com/en-us/dax/contains-function-daxhttps://learn.microsoft.com/en-us/dax/con...

Kudos and mark as solution appreciated 🙂

Its not working , could you please demonstrate an example here ?

It is probably not working, because you are tying to do a measure. Do calculated column.

Still not working. The else part isnt working. Highlighted in bold below: 

Test = IF('Reporting.Digital'[CampaignName]="abc","dcf",CONTAINS('Reporting.Digital','Reporting.Digital'[CostMethod],"P242V0D" || "Discovery Channel" || "Hulu" || "Select", 'Reporting.Digital'[CCD_Partner])

You are missing second IF statement
IF('Reporting.Digital'[CampaignName]="abc","dcf",
IF(CONTAINS('Reporting.Digital','Reporting.Digital'[CostMethod],"P242V0D" || "Discovery Channel" || "Hulu" || "Select")'Reporting.Digital'[CCD_Partner])

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Kudoed Authors