Forum Discussion
Anonymous
7 years agoNot applicable
Nested If to compare previous row value
Hello, Can anyone help me with the logic for creating nested IF statement in powerbi to get the output like below? I have already created an index based on date and time but I don't know how to kee...
- 7 years ago
Hi Anonymous ,
The following is a measure I created. And you can reference it to have a try.
Measure = var mi = MAX(Table1[Index]) var hei = CALCULATE(MAX(Table1[HEIGHT]),FILTER(ALLEXCEPT(Table1,Table1[DATE]),Table1[Index] = mi -1)) var col = CALCULATE(MAX(Table1[COLOR]),FILTER(ALLEXCEPT(Table1,Table1[DATE]),Table1[Index] = mi -1)) var size = CALCULATE(MAX(Table1[SIZE]),FILTER(ALLEXCEPT(Table1,Table1[DATE]),Table1[Index] = mi -1)) return IF(mi -1 = 0,BLANK(),IF(MAX(Table1[HEIGHT]) = hei , IF(MAX(Table1[COLOR]) = col, IF(MAX(Table1[SIZE]) = size, "M","A"),"B"),"D"))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-xuding-msft
7 years agoCommunity Support
Hi Anonymous ,
The following is a measure I created. And you can reference it to have a try.
Measure = var mi = MAX(Table1[Index]) var hei = CALCULATE(MAX(Table1[HEIGHT]),FILTER(ALLEXCEPT(Table1,Table1[DATE]),Table1[Index] = mi -1)) var col = CALCULATE(MAX(Table1[COLOR]),FILTER(ALLEXCEPT(Table1,Table1[DATE]),Table1[Index] = mi -1)) var size = CALCULATE(MAX(Table1[SIZE]),FILTER(ALLEXCEPT(Table1,Table1[DATE]),Table1[Index] = mi -1)) return IF(mi -1 = 0,BLANK(),IF(MAX(Table1[HEIGHT]) = hei , IF(MAX(Table1[COLOR]) = col, IF(MAX(Table1[SIZE]) = size, "M","A"),"B"),"D"))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.