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.
Is there a way we can replicate the below formula in power bi?
Solved! Go to Solution.
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.
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.
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 ?
Still not working. The else part isnt working. Highlighted in bold below:
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])
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 |
---|---|
104 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
147 | |
109 | |
107 | |
85 | |
63 |