Forum Discussion
Chanleakna123
7 years agoPost Prodigy
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 | Date | Value | Purchase/No Purchase | Count |
| 12345 | Abc | 1/1/2019 | 12 | Purchase | 1 |
| 12345 | Abc | 2/1/2019 | 23 | Purchase | 1 |
| 12345 | Abc | 3/1/2019 | 0 | No Purchase | 0 |
| 45678 | xyz | 1/1/2019 | 12 | Purchase | 1 |
| 45678 | xyz | 2/1/2019 | 23 | Purchase | 1 |
| 45678 | xyz | 3/1/2019 | 3 | Purchase | 1 |
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 | Count | Repurchased/No Repurchased |
| 12345 | Abc | 35 | Purchased | 2 | No Repurchased |
| 45678 | xyz | 38 | Purchased | 3 | Re Purchased |
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-msftMicrosoft Employee
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
- Chanleakna123Post 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-msftMicrosoft Employee
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