Forum Discussion
Switch Formula with multiples condition based off existing measures and a column i have created.
- 2 years ago
To implement the logic you described with a switch formula based on financial quarters and tolerance levels, you can use the `SWITCH` function along with additional `IF` statements to check the financial quarter and apply the appropriate tolerance criteria. Here's a DAX formula that accomplishes this:
```DAX
Result =
VAR CurrentQuarter = SELECTEDVALUE(Calendar[FYQ])
VAR Variance = [MONTH_%_DIFF]
VAR ToleranceLevel =
SWITCH(
TRUE(),
CurrentQuarter = "Q1 FY" && (Variance > 0.1 || Variance < -0.1), 500000,
CurrentQuarter = "Q2 FY" && (Variance > 0.1 || Variance < -0.1), 500000,
TRUE(), 100000
)
VAR WithinTolerance =
IF(
ABS(Variance) <= ToleranceLevel,
"In Tolerance",
"Outside Tolerance"
)
RETURN
WithinTolerance
```Here's how this formula works:
1. `CurrentQuarter` calculates the financial quarter based on your calendar table.
2. `Variance` represents the percentage difference that you have.
3. `ToleranceLevel` calculates the tolerance level based on the financial quarter and whether the variance exceeds 10%. If it's Q1 or Q2 and the variance exceeds 10%, the tolerance is 500,000. Otherwise, it's 100,000.
4. `WithinTolerance` checks whether the absolute value of the variance is within the calculated tolerance level and returns "In Tolerance" or "Outside Tolerance" accordingly.
5. The `Result` measure returns the result of the `WithinTolerance` calculation.
This formula considers the financial quarter, percentage variance, and appropriate tolerance level, and then returns "In Tolerance" or "Outside Tolerance" based on these conditions. Adjust the tolerance levels and conditions as needed to match your specific requirements.
hi, forgetmenot
try below
- forgetmenot2 years ago
Helper I
Thank you for taking the time to respond.
Apologies, It seems I have made a typo, it should have read that the tolerance should be +/-10% or 500,000 for Qtr1 or if its Qtr 2 then it should be +/-10% or 250,000.
so the checks that need to be done are first look at FY column (i added to dataset as a column so its not part of original dataset)ā
determine what Q it is,
if its Q1 then tolerance is +/-10% diff from previous Q or 500,000.
if its Q2 then tolerance is +/-10% diff from previous Q or 250,000, i hope that makes sense. so i need tio incorporate these additional criteria of dtermining the FYQ and applying 500,000 tolerance for Q1 or 250,000 tolerance f its Q2.- Dangar3322 years ago
Resident Rockstar
hi, forgetmenot
provide sample data
- forgetmenot2 years ago
Helper I