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.
I am trying to create a table using KEEPFILTERS with multiple OR conditions, but it seems that KEEPFIlTERS can only support AND relationships.
My scenario:
I want to filter out [Column 1], [Column 2], and [Amount] based on the conditions of [Type] OR [Category]. But KEEPFILTERS only allows an AND relationships. I want to see data that either matches [Type] condition OR [Category] condition.
EVALUATE
SUMMARIZECOLUMNS(
[Column 1],
[Column 2],
KEEPFILTERS(
TREATAS({XYZ},Type[Type])
),
KEEPFILTERS(
TREATAS({ABC},Catergory[Category])
),
[Amount]
)
Can anyone please tell me how to write the code? Thanks!
Solved! Go to Solution.
Hi, @ihungko
try to use union.
here is the documentation. UNION function (DAX) - DAX | Microsoft Learn
example code
DEFINE
TABLE TypeFilter =
CALCULATETABLE (
'YourTable',
TREATAS ( { "XYZ" }, 'YourTable'[Type] )
)
TABLE CategoryFilter =
CALCULATETABLE (
'YourTable',
TREATAS ( { "ABC" }, 'YourTable'[Category] )
)
EVALUATE
SUMMARIZECOLUMNS (
[Column 1],
[Column 2],
UNION ( TypeFilter, CategoryFilter ),
[Amount]
)
Proud to be a Super User!
Hi, @ihungko
try to use union.
here is the documentation. UNION function (DAX) - DAX | Microsoft Learn
example code
DEFINE
TABLE TypeFilter =
CALCULATETABLE (
'YourTable',
TREATAS ( { "XYZ" }, 'YourTable'[Type] )
)
TABLE CategoryFilter =
CALCULATETABLE (
'YourTable',
TREATAS ( { "ABC" }, 'YourTable'[Category] )
)
EVALUATE
SUMMARIZECOLUMNS (
[Column 1],
[Column 2],
UNION ( TypeFilter, CategoryFilter ),
[Amount]
)
Proud to be a Super User!