There's not really a good way to do this in the general case. If 'Table'[Col1] and 'Table'[Col2] have no duplicates, you can use one of SUMMARIZE() as shown above or GROUPBY() with identical syntax, but both of these perform a logical group by operation. This means that if you have duplicates, your table will have fewer rows AND fewer columnns than the base.
As @Greg_Deckler, mentioned, duplicating the query in Power Query is likely a better option.
I have a table with N Columns where I have (among others) the following columns and conditions A) There are 3 executing/managing sites (IN-HOUSE) B) There are 4 outsourcing sites (OFFSHORE) C) For every offshore Project, there must always be an IN-HOUSEManaging site
1) DEPARTMENT - Contains Coding/Managing site (Either in-house or Offshore) - IN-HOUSE_A,IN-HOUSE_B, IN-HOUSE_C, OFFSHORE_A, OFFSHORE_B, OFFSHORE_C, OFFSHORE_D 2) Project_Name 3) Plan_Date
a) If the project is being Managed and Coded 100% in-house in one SINGLE SITE, then there is just ONE record for that PROJECT in that DEPARTMENT in a certain PLAN_DATE, e.g.: DEPARTMENT = IN-HOUSE_A - (B or C) b) If the project is being Managed and Coded 100% in-house in more than one Executing Site, then there is ONE record for each Executing Site in the DEPARTMENT column for that PROJECT in a certain PLAN_DATE (in this case, it could be considered as separate projects since Budgeting is done at the Executing/Managing Site level) c) If a Project is sent offshore (it can be sent to 1 or more off-shore Coding sites), there would be two or more records i. One record with DEPARTMENT = "IN-HOUSE_A" -(B or C) ii. One record with DEPARTMENT = "OFFSHORE_A" -(B, C or D) for each off-shore site where code is being done
I want to find a way in DAX (or Power Query) to add a CUSTOM COLUMN in that table to indicate the Managing Site for each outsourced project for easier reporting and filtering, e.g.: a) Cost plan by Executing site for 100% managed projects b) Cost Plan by Coding site for outsourced projects c) Cost Plan by Managing Site-Coding Site
NOTES: To detect Managing Site, I was thinking on locate DUPLICATES (PROJECT_DATE + PLAN_DATE) then: i. locate the DEPARTMENT value for record containing DEPARTMENT = IN-HOUSE_X (A, B, or C) value ii. Locate it's associated records (with same PROJECT_DATE + PLAN_DATE) but DEPARTMENT = OFFSHORE_X (A, B, or C) and copy the IN-HOUSE department from the previous record to the Custom column, understanding that can be 1 or more offshore records|| iii. For unique records, I'd add a custom label (e.g.: "100% IN-HOUSE") or leave it blank in that Custom column
I can't change the design on the table since it comes from a C.A. Clarity PPM feed
I see what @SqlJason is saying but it seems a bit crazy to bring in two tables by query twice, once with one set of columns and once with another, call the second import of the tables SelectedColumns1 and SelectedColumns2
In my case I wanted to use EXCEPT to find rows in SelectedColumns1 not in SelectedColumns2; this requires the two tables have a) exactly the same number and type of columns, and b) the right columns to produce the required result i.e. no identity type columns
What I'd really like to be able to do is to use EXCEPT and create my SelectedColumns1 and SelectedColumns2 on the fly, as table expressions, which doesn't seem to be possible
In my case using CALCULATETABLE will remove some rows, as pointed out by @greggyb
I can't do what @Greg_Deckler says either as if you copy the table you get all columns and there's no way to hid columns, or rather if you do hide them, it affects only the reporting not the matching - I think
@JohnDawson - Don't copy the table, copy the query. Edit that query to remove the columns that you do not want. You now have 2 queries that create 2 tables, one with all the columns and one with fewer than all of the columns.