Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
John_Doe3
Helper II
Helper II

Assigning different categories to (nearly) identical tables

Greetings,

 

 

I will do my best to describe the problem:

 

I have a couple of excel sheets/tables from different trial locations, all containing pretty much the same columns / rows. I want to assign value "A" or value "B" to the data in these tables so I can filter for "A"or "B", and it will use only the data associated with either "A" or "B".

 

Example: 

Table 1 = A

Table 2 = B

Table 3 = B

Table 4 = A

 

When I select value A (by ways of slicer), I only want to see graphs derived from table 1 & table 4.

When I select value B, I only want to see graphs derived from table 2 & table 3.

 

I know it would be easier to add this in the excel, create a column and just load it with value A or B or something along those lines, but for reasons I won't go into, this is not an option. I need to be able to get the excel files the way they are and assign these labels to them with a transform somehow.

 

Is this doable? 

 

2 ACCEPTED SOLUTIONS
MarkLaf
Super User
Super User

Yes, you can just use the Add Custom Column button at the end of each table query and assign A or B, then combine the tables.

 

A fancier way to do it would be to manually assign the categories in one place as rows [Category = "A/B", TableColumnToExpand = Table]. Example:

 

let
    // List of manual assignments
    // One row of { "Assigned Value", Table } for each Table
    TableAssignmentRows =
    { 
        { "A", Table1 }, 
        { "B", Table2 }, 
        { "B", Table3 }, 
        { "A", Table4 } 
    },

    NameOfGroupingColumn = "Category",

    AddAssignments = List.Transform( 
        TableAssignmentRows,
        (assignments)=> 
        Table.ReorderColumns( 
            Table.AddColumn( 
                assignments{1}, NameOfGroupingColumn, 
                each assignments{0}, type text 
            ), 
            {NameOfGroupingColumn} & Table.ColumnNames( assignments{1} ) 
        )
    ),

    Combine = Table.Combine( AddAssignments )
in
    Combine

View solution in original post

v-sdhruv
Community Support
Community Support

Hi @MarkLaf ,

1.Load all Excel tables (Table1, Table2, etc.) into Power BI as separate queries.

If its Same workbook or file (on different sheets):

  • Go to Data tab → Click “Get Data” → “From Workbook”

  • Select the file with your tables

  • In the Navigator, select Table1 → Click Transform Data

  • In Power Query, go to Add Column → Custom Column

 

  • Name: GroupLabel 1
  • Formula:= "A"         // or "B" depending on the source
  • Click Close & Load To... → Only Create Connection

Repeat steps 1–5 for each table (Table2, Table3, etc.) assigning the correct label. 

2.  Combine the labeled tables: 

  • Go to Data → Get Data → Combine Queries → Append

  • In the Append dialog

    • Choose Append Queries as New

    • Select 3 or more tables (you’ll need to use the "Three or more tables" option if applicable)

This creates a new combined query that includes the  GroubLabel for each row.
3. Load to Excel

  • Right-click the new appended query → Close & Load To...

  • Choose to load it as a Table in a worksheet.

If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You!

 

View solution in original post

7 REPLIES 7
v-sdhruv
Community Support
Community Support

Hi @John_Doe3  ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @John_Doe3  ,
Just wanted to check if you had the opportunity to review the suggestions provided?
Apologies @MarkLaf 
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @John_Doe3  ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

@v-sdhruv, I am not the OP.

v-sdhruv
Community Support
Community Support

Hi @MarkLaf ,

1.Load all Excel tables (Table1, Table2, etc.) into Power BI as separate queries.

If its Same workbook or file (on different sheets):

  • Go to Data tab → Click “Get Data” → “From Workbook”

  • Select the file with your tables

  • In the Navigator, select Table1 → Click Transform Data

  • In Power Query, go to Add Column → Custom Column

 

  • Name: GroupLabel 1
  • Formula:= "A"         // or "B" depending on the source
  • Click Close & Load To... → Only Create Connection

Repeat steps 1–5 for each table (Table2, Table3, etc.) assigning the correct label. 

2.  Combine the labeled tables: 

  • Go to Data → Get Data → Combine Queries → Append

  • In the Append dialog

    • Choose Append Queries as New

    • Select 3 or more tables (you’ll need to use the "Three or more tables" option if applicable)

This creates a new combined query that includes the  GroubLabel for each row.
3. Load to Excel

  • Right-click the new appended query → Close & Load To...

  • Choose to load it as a Table in a worksheet.

If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You!

 

MarkLaf
Super User
Super User

Yes, you can just use the Add Custom Column button at the end of each table query and assign A or B, then combine the tables.

 

A fancier way to do it would be to manually assign the categories in one place as rows [Category = "A/B", TableColumnToExpand = Table]. Example:

 

let
    // List of manual assignments
    // One row of { "Assigned Value", Table } for each Table
    TableAssignmentRows =
    { 
        { "A", Table1 }, 
        { "B", Table2 }, 
        { "B", Table3 }, 
        { "A", Table4 } 
    },

    NameOfGroupingColumn = "Category",

    AddAssignments = List.Transform( 
        TableAssignmentRows,
        (assignments)=> 
        Table.ReorderColumns( 
            Table.AddColumn( 
                assignments{1}, NameOfGroupingColumn, 
                each assignments{0}, type text 
            ), 
            {NameOfGroupingColumn} & Table.ColumnNames( assignments{1} ) 
        )
    ),

    Combine = Table.Combine( AddAssignments )
in
    Combine

Hi MarkLaf,

 

Thank you for thinking along with me. However, it deserves mention that I'm not a coder by any stretch of the imagination and I would call myself a novice when it comes to Power BI / Excel. Where do I add the code you provided? 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors