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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Hlerm101
Frequent Visitor

Create column or new table with existing column and value

Hi BI developer,

I am BI beginer and need you help or advise.

 

I have a table as below. I want to keep some item from that table by specific number in column "Need Item No". 

 

ITEMDisplay_MODENeed Item No.
AA01AAA1112
BA03AAA1112
CC11AAA1112
DD12AAA1112
AA01BAB1015
BA03BAB1015
CC11BAB1015
DD12BAB1015
EA01BAB1015
ZA03BAB1015
MC11BAB1015
KD12BAB1015

 

All ITEM are the same priority but want to keep by  "Need Item No". 

 

For the result expected :-

 

1. Keep by new column by flag Y and N

 

ITEMDisplay_MODENeed Item No.Flag
AA01AAA1112Y
BA03AAA1112Y
CC11AAA1112N
DD12AAA1112N
AA01BAB1015Y
BA03BAB1015Y
CC11BAB1015Y
DD12BAB1015Y
EA01BAB1015Y
ZA03BAB1015N
MC11BAB1015N
KD12BAB1015N

 

2. Or create a new table.

 

ITEMDisplay_MODENeed Item No.
AA01AAA1112
BA03AAA1112
AA01BAB1015
BA03BAB1015
CC11BAB1015
DD12BAB1015
EA01BAB1015

 

 

 

Thank you.

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

I see that you've encountered some issues with the DAX formulas provided. Let's revise the DAX formulas to create the "Flag" column and the new table correctly.

  1. Creating the "Flag" Column:

    To create the "Flag" column, you can use the following DAX formula:

Flag = IF([Need Item No.] = CALCULATE(MAX(ItemMod[Need Item No.]), FILTER(ItemMod, [Display_MODE] = EARLIER([Display_MODE]))), "Y", "N")

 

  1. Make sure that ItemMod is replaced with the actual name of your table.

    This formula uses the CALCULATE and FILTER functions to find the maximum "Need Item No" for rows with the same "Display_MODE" as the current row. If the current row's "Need Item No" matches the maximum, it sets the "Flag" to "Y," otherwise "N."

  2. Creating the New Table:

    To create a new table with rows where the "Flag" is "Y," you can use the following DAX formula:

NewTable = FILTER(ItemMod, [Flag] = "Y")

 

  1. Again, ensure that ItemMod is replaced with the actual name of your table.

    This formula simply filters the existing table (ItemMod) to include only the rows where the "Flag" is "Y."

Make sure to use these revised DAX formulas, and you should be able to create the "Flag" column and the new table with the correct results in Power BI.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Hlerm101 ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
123abc
Community Champion
Community Champion

In Power BI, you can achieve your desired results by adding a new column to your existing table or by creating a new table. Below, I'll show you both methods:

Method 1: Adding a New Column

  1. Open your Power BI report and select the table containing your data.

  2. Click on the "Model" view to see your data model.

  3. Select your table and click on "New Column" in the formula bar.

  4. Use the following DAX formula to create a new column called "Flag":

Flag = IF([Need Item No.] = MAXX(FILTER(YourTable, [Display_MODE] = EARLIER([Display_MODE])), [Need Item No.]), "Y", "N")

 

Replace YourTable with the name of your table.

  1. Press Enter to create the new column.

Now, you should see the "Flag" column in your table, which will display "Y" or "N" based on your criteria.

Method 2: Creating a New Table

  1. In the "Model" view, right-click on the table containing your data and select "New Table."

  2. Use the following DAX formula to create a new table:

NewTable =
FILTER(
YourTable,
[Need Item No.] = MAXX(FILTER(YourTable, [Display_MODE] = EARLIER([Display_MODE])), [Need Item No.])
)

 

Replace YourTable with the name of your existing table.

  1. Press Enter to create the new table.

Now, you should have a new table called "NewTable" that contains only the rows that meet your criteria.

You can choose either method based on your preference, and it will give you the desired result in Power BI.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 

Hi @123abc 

Thank you.

But, as i try the result as below.

1 New column result is Y only.

Flag = IF([Need Item No.] = MAXX(FILTER(ItemMod, [Display_MODE] = EARLIER([Display_MODE])), [Need Item No.]), "Y", "N")

Hlerm101_1-1695524854765.png

 

 

2 I have try create new table but new table result is the same existing table.

NewTable =
FILTER(
ItemMod,
[Need Item No.] = MAXX(FILTER(ItemMod, [Display_MODE] = EARLIER([Display_MODE])), [Need Item No.])
)

Hlerm101_2-1695525090519.png

 

Thank you.

123abc
Community Champion
Community Champion

I see that you've encountered some issues with the DAX formulas provided. Let's revise the DAX formulas to create the "Flag" column and the new table correctly.

  1. Creating the "Flag" Column:

    To create the "Flag" column, you can use the following DAX formula:

Flag = IF([Need Item No.] = CALCULATE(MAX(ItemMod[Need Item No.]), FILTER(ItemMod, [Display_MODE] = EARLIER([Display_MODE]))), "Y", "N")

 

  1. Make sure that ItemMod is replaced with the actual name of your table.

    This formula uses the CALCULATE and FILTER functions to find the maximum "Need Item No" for rows with the same "Display_MODE" as the current row. If the current row's "Need Item No" matches the maximum, it sets the "Flag" to "Y," otherwise "N."

  2. Creating the New Table:

    To create a new table with rows where the "Flag" is "Y," you can use the following DAX formula:

NewTable = FILTER(ItemMod, [Flag] = "Y")

 

  1. Again, ensure that ItemMod is replaced with the actual name of your table.

    This formula simply filters the existing table (ItemMod) to include only the rows where the "Flag" is "Y."

Make sure to use these revised DAX formulas, and you should be able to create the "Flag" column and the new table with the correct results in Power BI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.