RICH937
Board Regular
- Joined
- Apr 15, 2023
- Messages
- 59
- Office Version
- 365
- Platform
- Windows
- Mobile
Hi folks. My data set has a few columns that are used to identify subsegments of other columns. For example, the "government" segment column has multiple subsegments like Army, Navy, Airforce, State Dept, etc. in another column. In the subsegment column, those segments that don't have subs are blank (blank rows in attached screenshot). Some of the analysis I am doing is on these subsegments, and I was having a hard time figuring out how to limit the data in a query to just those rows with subsegment data. I thought "remove blank rows" would work, but it did not. My work around was to do the following. I'm going to write a summary of what I did, just in case the M quick wrap doesn't work. First time using it. SUMMARY: I added a custom column named "Remover" and used a conditional on the segment (category) column that either resulted in the value from the subsegment [analyzed] column or the value from another column [madeup]. The second column did not exist, so an error was generated. I could then use the remove errors function to delete the rows that did not have a value in the subsegment column, and then delete the custom column "remover."
This works. However, I'm sure it's not the right way. Can someone tell me the correct way to go about this?
This works. However, I'm sure it's not the right way. Can someone tell me the correct way to go about this?
Power Query:
#"Added Custom" = Table.AddColumn(
REMOVE_Unused_COLUMNS,
"REMOVER",
each if [ANALYZED] <> "" then [ANALYZED] else [MADEUP]
),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Added Custom", {"REMOVER"}),
#"Removed Columns" = Table.RemoveColumns(#"Removed Errors", {"REMOVER"}),