Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello everyone!
I'm new to PowerQuery/PowerBI, I've got a table that I'd like to remove some rows if a rule applies.
What I need:
If column "VALID" has "YES" in the data, delete rows that contains "NO" (if they are the same information only).
I filtered the data to show the example below, in this case, I'd like to delete the first row that contains "NO" and keep only the row with "YES", because all the rest are the same.
If rows contains only the value "NO", so do nothing.
Example:Thanks!
Hi @Anonymous ,
We can use calculated table to work around instead of M code in power query.
CleanTable = VAR T = ALL ( 'table' ) VAR Y = FILTER ( T, [VALID] = "YES" ) VAR YN = SELECTCOLUMNS ( Y, "COD_EMPRS", [COD_EMPRS], "NUM_RGTRO_EMPRG", [NUM_RGTRO_EMPRG], "NUM_IDNTF_RPTANT", [NUM_IDNTF_RPTANT], "VALID", "NO", "EMP/MAT/REP", [EMP/MAT/REP] ) RETURN EXCEPT ( T, YN )
I couldn't open your file, it said my version was newer than yours.
But I'm going to merge this table with another table, so I need only one result.
Rule:
If has "YES" and "NO", keep only "YES".
Otherwise, bring wherever has in the column.
if you have to do it in M then the Group By + List.Max I posted earlier will do the job
I'd suggest using GroupBy with Max of VALID, like this
List.Max can be used with strings following alphabetic order, so Yes will always come ahead of No
I didn't try this solution yet, but I think it wont wok. Because I'm going to merge this table with another table, so it'll bring both results.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.