I have a table with few columns. Considering each distinct date, I want to create a calculated column based on the following rules:
- If [Shop] is "ADD_TO_CART" then [Number]
- If [Shop] is "PRODUCT_VIEW" then [Number] of "ADD_TO_CART" minus [Number] of "PRODUCT_VIEW"
- If [Shop] is "CHECKOUT" then [Number] of "PRODUCT_VIEW" minus [Number] of "CHECKOUT".
I have tried in different ways, but couldn't succeed.
This is how I have tried.
IF([Shop]="ALL_VISITS",0,
IF([Shop]="PRODUCT_VIEW",
CALCULATE(SUM(Number),FILTER(TableName,
[Shop]="ALL_VISITS"))-Number,
IF([Shop]="ADD_TO_CART",
CALCULATE(SUM(Number),
FILTER(TableName,[Shop]="PRODUCT_VIEW"))-Number,
IF([Shop]="CHECKOUT",
CALCULATE(SUM(Number),
FILTER(TableName,[Shop]="ADD_TO_CART"))-Number,
IF([Shop]="TRANSACTION",
CALCULATE(SUM(Number),
FILTER(TableName,[Shop]="CHECKOUT"))-Number,0)))))