How to use NOT IN Statement in Power BI case statements - powerbi

I am trying to write something like this in power BI using DAX and cant figure it out.
case when table.column_name NOT IN ( "I", "IP", "N", "T", "W",) THEN 1 END
any suggestions will be very appreaciated.

Related

In DAX, is the Whole Number "0" = Blank?

just trying to build a new column in Power BI through DAX
I am not sure why if the data COB to COB# is Zero or Blank, the result will show BLANK
so, if the COB to COB# data is showing 0, how can i show it as "0:00"?
Thank you!
Use == instead of just = if you want to be strict with your comparison.

if and search function on power BI token literal expected

I have a table called "food suppliers" with a column called "sites" that have multiple countries ending in ".com", ".es", ".co.uk".
I want to create a new column that separates these sites into their corresponding country names using the if and search function on power query.
so far in power query custom column I have:
Country = IF (SEARCH ("*.com", foodsuppliers[sites],,0) = 0, IF (SEARCH ("*.es", foodsuppliers[sites],, 0)= 0, "Spain","UK"),"USA")
But I am getting a "token literal expected" under the first = sign in "IF (SEARCH ("*.com", foodsuppliers[sites],,0) = 0"
does any one have ideas why or a better way to run this code on power query/power bi?
thanks.
Nothing in your code seems relevant
There is no SEARCH function, you want to use Text.Contains
You cant write foodsuppliers[sites] or you will be getting the entire column of all rows. You probably want each current row, which you would get with [sites]
This is not excel where you can do =if (xxx,fff,zzz) the format is if x then y else z
I recommend some tutorials

IF statement comparing the dates from same column

I have sql query like below : (have put only skeleton)
select
e1.empname,
case
when e1.date in {"20201001","20200102"}
and e2.date not in {"20200101","20200102","20200103"} then "entry"
when v1.date > v2.date then "exit"
when v1.date < v2.date then "detsined"
else "promoted"
end as "As usual"
from employee v1, employee v2
where v1.quarter= "2015 Q3"
I'm trying to write a equivalent dax measure. IF(table[datestring]>table[datestrin]) this is not working . I understand that we need to use the self join concept here. Can someone help me out here?
The feature is not available on power bi

Issue in applying filter in Power BI Desktop DAX forumla

I am facing an issue while working with power bi desktop. i am having an csv file as a datasource and i am having a column with multiple values, say "abc, def", "jkl" "zyz" etc.
Here, i need to generate a report with rows having showing "def" & "jkl" .
How to filter this using DAX Filter command. i wanted to fetch, filter only two values CTF& EVE in the Power BI report.
I tried with creating a calculated column and applied the below code but it didnt work:
Columnjkl = FILTER((Table1,OR(Table1[mycolumn1] == "def" || "jkl"))
filter-2cols-ctf-eve-
You need to read how DAX syntax is written, check this page to see how you use the FILTER function (FILTER) and this for how to use the OR function (OR)
Basically, Filter returns a table, so using it to calculate a column will not work. However, by implementing the FILTER function inside a CALCULATE you can change/modify what the main argument of CALCULATE will evaluate. The calculation flow in DAX is such that first the filter argument is evaluated and then the aggregation (or what ever) is evaluated. Example:
NumberOfRowsWithABC =
CALCULATE =
COUNTROWS('Table1'),
FILTER(
'Table1',
'table1[mycolumn1] = "abc"
)
)
First the FILTER function only selects the rows in 'Table1' where [mycolumn1] has the text value abc. Then it passes this reduced table to the COUNTROW function, which counts the number of rows in the table passed to it.
The syntax for the OR function is wrong. This is how you should write it:
OR(
'Table1'[mycolumn1] = "def",
'Table1'[mycolumn1] = "jkl"
)
Perhaps a better way of writing this OR function is using the in-command as the filter argument of the calculate function:
NumberOfRowsWith_def_and_jkl =
CALCULATE(
COUNTROWS('Table1'),
'Table1'[mycolumn1] in {"def", "jkl"}
)
But as Gangula wrote, you don't need to filter 'Table1' using the FILTER function, it can all be done visually on the dashboard.

Power BI: How to pull in a column to an IF statement

I am trying to create a measure that says (basically) if the value in a column doesn't exists, display "No", otherwise display the column. Currently, I can't get this to pull in the column. This is essentially what I'm trying to accomplish
Status = IF(Table[Column] = BLANK(), "No", Table[Column])
Currently, the only thing I can get to work is this:
Status = IF(CALCULATE(COUNTA(Table[Column])) = BLANK(), "No", "Yes")