Forum Discussion

Stevefranck's avatar
Stevefranck
Frequent Visitor
4 years ago
Solved

classify according row

hello , 

I need our help please ! 

Descriptions        

location GabaritBrandNewBrand
T1A256DAother
T1D456DIDI
T1F5335DAother
T2C5679DAother
T2D5678DIDI
T2F6543DAother
T3D07766DIDI
T3F755DAother
T3H6567DAother
T4D643DIDI
T4G665DAother
T5D543DIDI
T6D098DIDI
T6Z5433DAother
T6E9876DADI
T7F567DADA
T8S654DADA
T9D986DIDI
T10A285DADA
T11O943DADA

  

For start i have for information Location , Gabarit , Brand 

For the same Location if we have several Gabarit and one of the Gabarit starts with "D" then the new Brand  will be "DI" and the rest of the Gabarit of the same Location will have as new Brand "Other"

If for a Location we have no Gabarit starting with "D" then the new brand will be unchanged

Thank you for your help.

  • Samarth_18's avatar
    Samarth_18
    4 years ago

    Stevefranck Good to know it solved your problem. Kindly mark my solution as accepted solution so that it will help other to find it more quickly. 😊

4 Replies

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi Stevefranck ,

     

    Please try this:-

    New Brand =
    VAR _count =
        CALCULATE (
            COUNT ( 'Table (2)'[location ] ),
            FILTER (
                ALL ( 'Table (2)' ),
                'Table (2)'[location ] = EARLIER ( 'Table (2)'[location ] )
            )
        )
    VAR _gabrit =
        IF ( LEFT ( 'Table (2)'[Gabarit], 1 ) = "D", "DI", "other" )
    RETURN
        IF ( _count = 1, 'Table (2)'[Brand], _gabrit )

     

    output:-

    Thanks,

    Samarth

    • Stevefranck's avatar
      Stevefranck
      Frequent Visitor

      Hello,

      Thank you very much, it works very well

       

      Steve.

      • Samarth_18's avatar
        Samarth_18
        Community Champion

        Stevefranck Good to know it solved your problem. Kindly mark my solution as accepted solution so that it will help other to find it more quickly. 😊