Forum Discussion
Datorama Calculations to Power BI
Is there a way we can replicate the below formula in power bi?
- Anonymous2 years ago
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.
6 Replies
- zenisekd
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/contains-function-dax
Kudos and mark as solution appreciated 🙂 - AnonymousNot 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.