计算在第一笔订单中使用折扣的用户数
Calculate count of users which use the discount in their first order
如何计算在 Power BI 中第一笔订单使用折扣的用户数?
例如,在此数据中,结果应为 2 个用户或 50% 的用户:
我们可以这样做。首先,计算 user_id 的最短购买日期,然后检查折扣是否大于 0:
FirstOrderWithDiscount =
var _tempTab = TREATAS(
CALCULATETABLE(ADDCOLUMNS(VALUES(DiscountTab[user_id]),"minPurch", calculate(min('DiscountTab'[purchase_date]), ALLEXCEPT(DiscountTab, 'DiscountTab'[user_id]))), DiscountTab[discount] > 0)
, DiscountTab[user_id], DiscountTab[purchase_date])
return
CALCULATE( countrows(DiscountTab), _tempTab, DiscountTab[discount] > 0)
如何计算在 Power BI 中第一笔订单使用折扣的用户数?
例如,在此数据中,结果应为 2 个用户或 50% 的用户:
我们可以这样做。首先,计算 user_id 的最短购买日期,然后检查折扣是否大于 0:
FirstOrderWithDiscount =
var _tempTab = TREATAS(
CALCULATETABLE(ADDCOLUMNS(VALUES(DiscountTab[user_id]),"minPurch", calculate(min('DiscountTab'[purchase_date]), ALLEXCEPT(DiscountTab, 'DiscountTab'[user_id]))), DiscountTab[discount] > 0)
, DiscountTab[user_id], DiscountTab[purchase_date])
return
CALCULATE( countrows(DiscountTab), _tempTab, DiscountTab[discount] > 0)