Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I am attempting to create a custom conditional column in PowerQuery. The goal is to create a column in my data set named "Picklist Update Needed" which will display a simple 'Yes' or 'No' for each row.
There are four columns in my data set ('On POS', 'Add-Short', 'Picklist Updated', 'Cancellation') that are involved in the logic for this column, below is chart showing the conditions that would result in a 'Yes' to populate in the custom conditional column.
| On POS | Add - Short | Picklist Updated | Cancellation |
| No | Add | No | BLANK |
| No | Short | No | BLANK |
| Yes | Short | No | BLANK |
If the combinations are anything other than these three above, the result would be 'No'.
What would the DAX code look like to create this?
Solved! Go to Solution.
Here is a column expression that shows one way to do it. Replace MultiColumn with your actual table name.
NewColumn =
VAR picklistcancellation =
AND (
MultiColumn[Picklist Updated] = "No",
MultiColumn[Cancellation] = "BLANK"
)
VAR otherconditions =
OR (
OR (
AND ( MultiColumn[On POS ] = "No", MultiColumn[Add - Short] = "Add" ),
AND ( MultiColumn[On POS ] = "No", MultiColumn[Add - Short] = "Short" )
),
AND ( MultiColumn[On POS ] = "Yes", MultiColumn[Add - Short] = "Short" )
)
RETURN
IF ( AND ( picklistcancellation, otherconditions ), "Yes", "No" )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Here is a column expression that shows one way to do it. Replace MultiColumn with your actual table name.
NewColumn =
VAR picklistcancellation =
AND (
MultiColumn[Picklist Updated] = "No",
MultiColumn[Cancellation] = "BLANK"
)
VAR otherconditions =
OR (
OR (
AND ( MultiColumn[On POS ] = "No", MultiColumn[Add - Short] = "Add" ),
AND ( MultiColumn[On POS ] = "No", MultiColumn[Add - Short] = "Short" )
),
AND ( MultiColumn[On POS ] = "Yes", MultiColumn[Add - Short] = "Short" )
)
RETURN
IF ( AND ( picklistcancellation, otherconditions ), "Yes", "No" )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Wow! Thank you! That worked perfectly. I will have to study exactly what you did there because it certainly isn't what I was thinking, which I couldn't get to work.
Thanks again!
Hi @Anonymous
I think you missed to add the condition chart?
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Looks like I got a solution already. Thanks for helping out.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 34 | |
| 31 | |
| 30 |