The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi there,
After much searching and attemps, I can't seem to get this to work. I'm trying to create a calculated field where if the Program Type column contains either "NAPIS" "Meals (AWD)" or "Meals AWD" AND the Received Unit(s) column is "No" then it is marked "Exclude", else "Include". I've tried to use "IN" but it doesn't like that. The problem with the below seems to be that there's a space in some of the terms, but I thought the point of parentheses is to show it's a text string and therefore can contain spaces. Thank you so much in advance!! I really have tried many different ways of acheiving the desired result, to no avail.
*Program Type = switch(true(),
Containsstring('CAGC Export FY 2021 - RF'[Program Type], "napis*")
|| Containsstring('CAGC Export FY 2021 - RF'[Program Type], “*Meals (AWD)”)
|| Containsstring('CAGC Export FY 2021 - RF'[Program Type], “*Meals AWD”)
AND Containsstring('CAGC Export FY 2021 - RF'[Received Unit(s)], “No”),
“Exclude”,
“Include”
Solved! Go to Solution.
Hi @RodFinetti
Try this code to add a new column to your table:
IN or Out =
SWITCH (
TRUE (),
CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Program Type], "napis" )
&& CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Received Unit(s)], "NO" ), "Exclude",
CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Program Type], "Meals (AWD)" )
&& CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Received Unit(s)], "NO" ), "Exclude",
CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Program Type], "Meals AWD" )
&& CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Received Unit(s)], "NO" ), "Exclude",
"Include"
)
Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos🙏!!
Hi @RodFinetti
Try this code to add a new column to your table:
IN or Out =
SWITCH (
TRUE (),
CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Program Type], "napis" )
&& CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Received Unit(s)], "NO" ), "Exclude",
CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Program Type], "Meals (AWD)" )
&& CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Received Unit(s)], "NO" ), "Exclude",
CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Program Type], "Meals AWD" )
&& CONTAINSSTRING ( 'CAGC Export FY 2021 - RF'[Received Unit(s)], "NO" ), "Exclude",
"Include"
)
Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos🙏!!
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |