Forum Discussion
Dynamic filter on a table, then EXCEPT on it
Hello the Power BI community,
after a lot of work, i'm stuck. I tried several AI help in order not to bother humans, but they circle their answers eventually.
Here is what i'm trying to achieve :
i have a Table1 with a column Number1, a column Filter1, and other columns,
i have a Table2 with a column Number1, and other columns,
i must find a way to get this result :
after setting a filter on Filter1 on a visual, i need a table FinalTable having all lines containing each number of Number1 in Table2 that is NOT in Table1 when the value of Filter1 is the filter. (I went for just the column of Number1 first, i can always add later the other columns.)
So naturally i went for an EXCEPT, but it seems Power BI cannot calculate things based on a visual. So the last way is, apparently, to use calculated columns and measures after capturing the value of the filter with
CapturedFilter = SELECTEDVALUE('AnotherTableWithUniqueValuesOfFilter1'[Filter1])
to then create a calculated intermediary table
IntermediaryTable =
VAR SelectedFilter = [CapturedFilter]
RETURN
CALCULATETABLE (
VALUES ( 'Table1'[Number1] ),
FILTER (
'Table1',
'Table1'[Filter1] = CapturedFilter &&
'Table1'[Filter1] <> "" &&
TRIM('Table1'[Filter1]) <> ""
)
)
then the final result table would be something like :
FinalTable =
EXCEPT(
SELECTCOLUMNS(Table2, "Filter1", Table2[Filter1]),
SELECTCOLUMNS(IntermediaryTable, "Filter1", IntermediaryTable[Filter1])
)
but my IntermediaryTable is empty and i can't find why...
edit: should i add, of course, that i manually checked many of the 11000 rows of Table1 and Table2, that there is a link between them on Number1, yes that link works since i use them all the time on 8 other pages filled with working visuals, yes it's the same Text format and Text type of data in Number1 (yes, text, and it's normal, sorry for calling it Number1 here)... The "<> "" " and "TRIM" are to make sure to remove all empty and blank entries of Number1. I did many checks of the intermediary values, changes to the Filter, but nope, can't find out where the problem is.
You may correct this or find me an entirely new solution, i'll be happy anyway.
Sorry if i made any mistake writing all this, i admit i'm really tired. I'll correct if i or you find any.
Thanks a lot for any help.
8 Replies
- dufoq3Community Champion
Hi Anonymous,
- you send your request to PowerQuery forum but you are probably asking for DAX solution
- it would be better if you provide sample data in usable format (read note below if you don't know how to do it) and expected result based on sample data
- AnonymousNot applicable
Hello,
you're probably right. Should i try to remove this post and recreate it in DAX solutions' category ?
Here are a few examples of data :
3 rows of Table 1 :
Number1 | Filter1
5239 | APAOR
8558 | APCA
4536 | DIS3 rows of Table 2 :
Number1
5239
4536
8426
Expected results :
if my Filter1 is set on APAOR, i expect the IntermediaryTable to show
Number1
5239and the EXCEPT to show
Number1
4536
8426Thanks for your help.
- dufoq3Community Champion
If you have distinct values in Table1 [Number1] column, create One to Many relationship between Number columns and you can start using filter as described.
- AnonymousNot applicable
I'm afraid it simply cannot be done, because
1) a slicer value cannot be used in a calculated table,
2) when i use a measure, which is supposed, according to other sources, to be able to retrieve the slicer value, it doesn't work... but maybe i do it wrong?..