Forum Discussion

Chanleakna123's avatar
Chanleakna123
Post Prodigy
7 years ago
Solved

Column Calculation not get right

Hi All , 

 

I have such below Table , Column of Purchase/No PUrchase ; Count are calculated in Edit Query , as of result this is the table  : 

Customer Code Customer Name DateValue Purchase/No Purchase Count
12345Abc1/1/201912Purchase1
12345Abc2/1/201923Purchase1
12345Abc3/1/20190No Purchase 0
45678xyz1/1/201912Purchase1
45678xyz2/1/201923Purchase1
45678xyz3/1/20193Purchase1

 

Expected Result : 

I wanna calculated which customer who re purchased and Non : 

 

If Count >=3 , Repurchased , 

If Count < 3 , No Repurchased , 

I have calculated below columns : 

 

RE-Purchased = IF('Energy Drink'[Count on Purchased]>=RELATED('Master Outlet'[Count Outlet]),"Repurchased","No Repurchased") 
but the result turn all to No Repurchased 
Customer Code Customer Name Value Purchase/No Purchase CountRepurchased/No Repurchased
12345Abc35Purchased 2No Repurchased
45678xyz38Purchased 3Re Purchased 

  • v-cherch-msft's avatar
    v-cherch-msft
    7 years ago

    Hi Chanleakna123 

     

    Please check below dax.

    Count = 
    CALCULATE (
        COUNT ( 'Energy Drink'[Customer Name - Store host code] ),
        FILTER (
            ALLSELECTED ( 'Energy Drink' [Customer Name - Store host code]),
           [Repurchased/No Repurchased]= SELECTEDVALUE('Re-Purchased/No Repurchased'[Type])
        )
    )

    Regards,

    Cherie

12 Replies

  • v-cherch-msft's avatar
    v-cherch-msft
    Microsoft Employee

    Hi Chanleakna123 

     

    You may try to create a measure like below.If it is not your case,please show me the Master Outlet table.

    RE-Purchased =
    IF (
        SUM ( 'Energy Drink'[Count on Purchased] )
            >= MAX ( 'Master Outlet'[Count Outlet] ),
        "Repurchased",
        "No Repurchased"
    )
    

    Regards,

    Cherie

    • Chanleakna123's avatar
      Chanleakna123
      Post Prodigy

      v-cherch-msft  , hi the calculation works perfect , but can i have it in Column ? It will be easy to filter or slicer. of Repurchased or no Repurchased. 

      • v-cherch-msft's avatar
        v-cherch-msft
        Microsoft Employee

        Hi Chanleakna123 

         

        You may try below dax:

        Column =
        IF (
            CALCULATE (
                SUM ( 'Energy Drink'[count] ),
                ALLEXCEPT ( 'Energy Drink', 'Energy Drink'[Customer Code ] )
            )
                >= RELATED ( 'Master Outlet'[Count Outlet] ),
            "Repurchased",
            "No Repurchased"
        )
        

        Regards,

        Cherie