Forum Discussion
DAX IF condition with Lookup
- Anonymous3 years ago
Hi Anonymous ,
According to your description, you want to convert the excel formula to dax. In your code , it seems to get the flag data by the ‘Look Table’[Age].
If this , here are the steps you can refer to :
(1)My test data is the same as yours.(2)We can click “New Column” and enter this :
Column = var _Poor=MAXX( FILTER('Look Table','Look Table'[Approach]="Poor") , [Age]) var _Marginal=MAXX( FILTER('Look Table','Look Table'[Approach]="Marginal") , [Age]) var _Adequate=MAXX( FILTER('Look Table','Look Table'[Approach]="Adequate") , [Age]) var _Good=MAXX( FILTER('Look Table','Look Table'[Approach]="Good") , [Age]) return SWITCH(TRUE(), [ Life]<= _Poor,5, [ Life]>_Poor &&[ Life]<=_Marginal,4, [ Life]>_Marginal &&[ Life]<=_Adequate,3, [ Life]>_Adequate &&[ Life]<=_Good,2, 1)(3)Then we can meet your need ,the result is as follows:
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
According to your description, you want to convert the excel formula to dax. In your code , it seems to get the flag data by the ‘Look Table’[Age].
If this , here are the steps you can refer to :
(1)My test data is the same as yours.
(2)We can click “New Column” and enter this :
Column = var _Poor=MAXX( FILTER('Look Table','Look Table'[Approach]="Poor") , [Age])
var _Marginal=MAXX( FILTER('Look Table','Look Table'[Approach]="Marginal") , [Age])
var _Adequate=MAXX( FILTER('Look Table','Look Table'[Approach]="Adequate") , [Age])
var _Good=MAXX( FILTER('Look Table','Look Table'[Approach]="Good") , [Age])
return
SWITCH(TRUE(),
[ Life]<= _Poor,5,
[ Life]>_Poor &&[ Life]<=_Marginal,4,
[ Life]>_Marginal &&[ Life]<=_Adequate,3,
[ Life]>_Adequate &&[ Life]<=_Good,2,
1)
(3)Then we can meet your need ,the result is as follows:
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.