Forum Discussion

Hlerm101's avatar
Hlerm101
Frequent Visitor
3 years ago
Solved

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".    ITEM Display...
  • 123abc's avatar
    123abc
    3 years ago

    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.