Forum Discussion
DAX for calculating retroactive values
- 6 months ago
Hi Rai_Lomarques,
Could you please try using below DAX queries and let me know if it helps resolev your query.
Monthly Bonus
==============
Monthly Bonus =
VAR MonthlyReach = MAX('Bonus Data'[Monthly Reach %])
VAR BonusValue = 2700RETURN
IF(MonthlyReach >= 1, BonusValue, 0)Advance Bonus
=============
Pays when monthly is below target but the running YTD compensates (≥ 100%).Advance Bonus =
VAR MonthlyReach = MAX('Bonus Data'[Monthly Reach %])
VAR YTDReach = MAX('Bonus Data'[YTD Reach %])
VAR BonusValue = 2700RETURN
IF(
MonthlyReach < 1 && YTDReach >= 1,
BonusValue,
0
)Recovery Bonus
==============Recovery Bonus =
VAR CurrentDate = MAX('Bonus Data'[Month])
VAR CurrentYTD = MAX('Bonus Data'[YTD Reach %])
VAR BonusValue = 2700-- All months before current with no bonus (monthly < 100% AND YTD < 100%)
VAR EligibleMonths =
FILTER(
ALL('Bonus Data'),
'Bonus Data'[Month] < CurrentDate
&& 'Bonus Data'[Monthly Reach %] < 1
&& 'Bonus Data'[YTD Reach %] < 1
)-- For each eligible month, pay it only if the current month is
-- the FIRST month after it where YTD >= 100%
VAR RecoveredThisPeriod =
SUMX(
EligibleMonths,
VAR EligibleMonth = 'Bonus Data'[Month]-- Earliest future month with YTD >= 100%
VAR FirstRecoveryMonth =
MINX(
FILTER(
ALL('Bonus Data'),
'Bonus Data'[Month] > EligibleMonth
&& 'Bonus Data'[YTD Reach %] >= 1
),
'Bonus Data'[Month]
)-- Count this eligible month only if current = first recovery month
RETURN
IF(FirstRecoveryMonth = CurrentDate, BonusValue, 0)
)RETURN
IF(CurrentYTD >= 1, RecoveredThisPeriod, 0)Thanks,
Prashanth
We would like to confirm if our community members answer resolves your query or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are happy to help you.
Thank you for your patience and look forward to hearing from you.
Best Regards,
Prashanth Are
MS Fabric community support