Forum Discussion
Delete rows only if
- 2 years ago
Keks Try:
Measure = VAR __Seq = MAX('Table'[Sequence]) VAR __Result = SWITCH(TRUE(), MAX('Table'[Description]) = "Changed Qty", 1, COUNTROWS(FILTER(ALL('Table'), [Sequence] = __Seq)) = 1, 1, 0 ) RETURN __Result
Keks OK, well, the measure returns 1 for the rows you want and 0 for the rows you don't want. Then you just use the Filters pane to filter for a value of 1. This removes the 0's from your visual. It's a version of a Complex Selector. The Complex Selector - Microsoft Fabric Community
If you want to actually delete, delete the rows you would need to do that in Power Query but PQ doesn't have a switch statement so you would have to use nested if then else statements. PBIX is attached below signature.
It is working perfecly well... So thank you.
I just need to understand all the functions used :-).
One more time, thank you!
- Keks2 years agoFrequent Visitor
Greg_Deckler not possible to use this measure in a slicer or a filter. How can I do ? 😞
- Greg_Deckler2 years agoCommunity Champion
Keks Updated PBIX. You can use a Measure in the Filters pane for visual level filters only (not page or report level filters). OK, so MAX just gets teh maximum value in context. You have to use an aggregation function when referring to columns. The SWITCH(TRUE() ) statement is a fancy way of doing nested IF statements much more cleanly. So when using SWITCH(TRUE() ), the rest of the parameters come in pairs. The first part of the pair is something that returns a logical true or false and the second part of the pair is what to return if the statement is true. So, the first pair just checks to see if the Description is Changed Qty and if so, returns 1. The second counts all the rows in the table where the Sequence is the current sequence in context (__Seq variable) and if that count is equal to 1 it returns 1. If neither of these conditions is met, it returns 0.
- Keks2 years agoFrequent Visitor
Hi Greg_Deckler ,
Finally, I would like to delete rows (they are useless) in the data instead of flagguing it by a measure.How can I do that ?