Forum Discussion
Complex Filtering
- Anonymous8 years ago
Hi mjones24,
Default filter feature will use 'and logic to link all filters, so your customers goal is impossible to achieve through default filter.
I'd like to write a measure to check conditions and return the result tag, then you can filter the result tag to filter the records who suitable the complex filter conditions.
Sample:
Filter Tag = VAR current_attr1 = LASTNONBLANK ( 'Table'[Attribute 1], 1 ) VAR current_attr2 = LASTNONBLANK ( 'Table'[Attribute 2], 1 ) VAR current_attr3 = LASTNONBLANK ( 'Table'[Attribute 3], 1 ) VAR current_attr4 = LASTNONBLANK ( 'Table'[Attribute 4], 1 ) VAR result = OR ( AND ( current_attr1 IN { "a", "b" }, current_attr2 IN { "c", "d" } ), AND ( current_attr3 IN { "a", "b" }, current_attr4 IN { "c", "b" } ) ) RETURN IF ( result, 1, 0 )Notice:
1. You can modify the AND,OR functions to change the link logic.
2. If you want to add more conditions items, you can increase original items in variable list.(e.g. current_attr1 IN { "a", "b" ,"c", "d"})
Regards,
Xiaoxin Sheng
Hi mjones24,
Default filter feature will use 'and logic to link all filters, so your customers goal is impossible to achieve through default filter.
I'd like to write a measure to check conditions and return the result tag, then you can filter the result tag to filter the records who suitable the complex filter conditions.
Sample:
Filter Tag =
VAR current_attr1 =
LASTNONBLANK ( 'Table'[Attribute 1], 1 )
VAR current_attr2 =
LASTNONBLANK ( 'Table'[Attribute 2], 1 )
VAR current_attr3 =
LASTNONBLANK ( 'Table'[Attribute 3], 1 )
VAR current_attr4 =
LASTNONBLANK ( 'Table'[Attribute 4], 1 )
VAR result =
OR (
AND ( current_attr1 IN { "a", "b" }, current_attr2 IN { "c", "d" } ),
AND ( current_attr3 IN { "a", "b" }, current_attr4 IN { "c", "b" } )
)
RETURN
IF ( result, 1, 0 )
Notice:
1. You can modify the AND,OR functions to change the link logic.
2. If you want to add more conditions items, you can increase original items in variable list.(e.g. current_attr1 IN { "a", "b" ,"c", "d"})
Regards,
Xiaoxin Sheng
- mjones248 years agoFrequent Visitor
Thank you, very helpful.
- Anonymous5 years agoNot applicable
Thank you, that is very interesting, but can you explain please why you use the LASTNONBLANK function. That seems to be something to make it work and not related to the requirements.
Thanks,
Ashley.