How can I calculate the count of users which use discounts in their first order, in Power BI?
for example, in this data, the results should be 2 users or 50% of users:
We can do that this way. First, calculate min purchase date for user_id then check if discount is greater than 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)