Forum Discussion
TRADER083
Helper II
9 months agoUsing a string as parameter within IN operator
Hi everyone, I want to use a list as a filter based on a condition, however the following code indicates that final_list is not a valid table. The code will work if I use list1 or list2 directly,...
- 9 months ago
I tried recreating your problem by making a test table:
TestInputTable =DATATABLE("Code", STRING,"DummyValue", INTEGER,{{ "123", 10 },{ "456", 20 },{ "789", 30 }})
After this I tried with dax to create a new calculated table that filters the original table based on a condition. I don't know which condition your using so I made a true/false condition in the dax code that could easily be switched out.
I made the table as follows:Filtered TestInputTable =VAR list1 = { "123", "456" }VAR list2 = { "789" }VAR UseList1 = TRUE() -- of jouw echte conditieRETURNFILTER ('TestInputTable',IF (UseList1,'TestInputTable'[Code] IN list1,'TestInputTable'[Code] IN list2))This results in a filtered calculated table:and when condition is FALSE:
Hope this is helpfull
Anonymous
9 months agoNot applicable
Hi TRADER083 ,
Try below code.
VAR FinalList =
IF(
condition,
ROW("Value","123") & ROW("Value","456"),
ROW("Value","789")
)
RETURN
FILTER(table, table[column] IN FinalList
[Value])
If my response as resolved your issue please mark it as solution and give kudos.
- TRADER0839 months ago
Helper II
Thanks Anonymous, unfortunately, it didn't work.