Forum Discussion
DAX formula Not working
Hi sixathur
You're on the right track, and the issue likely stems from how measures work in Power BI. Since TOTAL VISITS is a measure, it dynamically evaluates based on the current filter context, which means you need to carefully control its aggregation to ensure only visits above 58 are counted.
try this
Extra_Visit_Cost =
SUMX(
VALUES('YourTable'[Week]), -- Iterate over each week
VAR VisitCount = [TOTAL VISITS] -- Get total visits for the current week
RETURN IF(VisitCount > 58, (VisitCount - 58) * 15, 0)
)
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Hi,
Thank you for your help, the formula worked but when I use the card visual for this measure, its still giving me the total of the visits*15, not the difference*15.
- mdaatifraza55561 year ago
Super User
Hi sixathur
Please try my above DAX.
belowis the snapshot which i have triedFor_Visits_more_than_58 =VAR Visits_Above_58 =SUMX(VALUES('Date'[weekno]),MAX([TotalVisits] - 58,0) * 15)RETURNVisits_Above_58--------------------------------------------
If total visits is less than 60 then it shows 0
Please accept it as a solution if you got your answer.