Forum Discussion

Rigolleto's avatar
Rigolleto
Icon for Resolver I rankResolver I
7 years ago
Solved

Create a new column with only one value

Hi,

Somebody could help me or give me some code to build a new column, "new column", how can you see the "sale LY" has duplicated the sales for the grouping season/grm/style, Do I need is to create a new column and left only one value, as the scheen shown, for every single group, I did try a max and sum, but my lack of knowledge is killing me

 

Thanks in advance

 

 

 

 

  • Hi Rigolleto ,

     

    We can create a calculate column using following DAX to meet your requirement.

     

    New column = 
    VAR season = [season]
    VAR grm = [grm]
    VAR style = [style]
    VAR ft =
        FILTER (
            ALL ( Example ),
            'Example'[season] = season
                && 'Example'[grm] = grm
                && 'Example'[style] = style
        )
    RETURN
        IF ( [sales] = MAXX ( ft, [sales] ), [salesLY], BLANK () )

     

    BTW, pbix as attached.

     

    Community Support Team _ DongLi
    If this post helps, then please consider Accept it as the solution to help the other members find it more 

1 Reply

  • v-lid-msft's avatar
    v-lid-msft
    Icon for Community Support rankCommunity Support

    Hi Rigolleto ,

     

    We can create a calculate column using following DAX to meet your requirement.

     

    New column = 
    VAR season = [season]
    VAR grm = [grm]
    VAR style = [style]
    VAR ft =
        FILTER (
            ALL ( Example ),
            'Example'[season] = season
                && 'Example'[grm] = grm
                && 'Example'[style] = style
        )
    RETURN
        IF ( [sales] = MAXX ( ft, [sales] ), [salesLY], BLANK () )

     

    BTW, pbix as attached.

     

    Community Support Team _ DongLi
    If this post helps, then please consider Accept it as the solution to help the other members find it more