Forum Discussion
DAX Expression for comparing rows
- 8 years ago
Hey,
I used this DAX statement to create a calculated column:
calc Rate Level Current = var currentPM = 'Table1'[PM] var currentForecast = 'Table1'[Current Forecast] var smallerScenarioRate = CALCULATE( MAX('Table1'[Scenario Rate]) ,FILTER( ALL('Table1') ,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] < currentForecast ) ) return CALCULATE( MAX('Table1'[Rate Level]) ,FILTER( ALL('Table1') ,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] = smallerScenarioRate ) )This returns these values:
And here is a small PBIX file
Hopefully this is what you are looking for.
Regards
Tom
Hey,
I used this DAX statement to create a calculated column:
calc Rate Level Current =
var currentPM = 'Table1'[PM]
var currentForecast = 'Table1'[Current Forecast]
var smallerScenarioRate =
CALCULATE(
MAX('Table1'[Scenario Rate])
,FILTER(
ALL('Table1')
,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] < currentForecast
)
)
return
CALCULATE(
MAX('Table1'[Rate Level])
,FILTER(
ALL('Table1')
,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] = smallerScenarioRate
)
)This returns these values:
And here is a small PBIX file
Hopefully this is what you are looking for.
Regards
Tom
- sentsara8 years agoHelper II
Hi Tom,
Thanks for taking time and provided with good example. i forgot to say one more thing. Current Forecast is the calculated column which is defined in another Dataset.i think thats the reason circular dependency was detected error is thrown.
I'm getting error as : "Circular Dependency was detected:"
calc Rate Level Current =
var currentPM = 'Table1'[PM]
var currentForecast = 'Table1'[Current Forecast] -- it comes from QRI DATASET --UNDER QRI Dataset it has derived as caculated column
var smallerScenarioRate =
CALCULATE(
MAX('Table1'[Scenario Rate])
,FILTER(
ALL('Table1')
,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] < currentForecast
)
)
return
CALCULATE(
MAX('Table1'[Rate Level])
,FILTER(
ALL('Table1')
,'Table1'[PM] = currentPM && 'Table1'[Scenario Rate] = smallerScenarioRate
)
)