Forum Discussion
DAX IF EARLIER
Gostaria de inserir uma coluna no powerpivot que gere o resultado conforme coluna calculada abaixo.
Lógica do resultado da coluna calculada: Se o texto da linha da coluna TIPO for igual ao texto da linha anterior (linha acima) da coluna TIPO então "NC" senão retorna o mesmo valor da mesma linha da coluna TIPO
Obs. a coluna formula é o que estou atualmente utilizando em tabela simples do excel para gerar o resultado
| TIPO | COLUNA CALCULADA | FORMULA |
| REC | REC | SE(E20=E19;"NC";E20) |
| REC | NC | SE(E21=E20;"NC";E21) |
| PLAY | PLAY | SE(E22=E21;"NC";E22) |
| PLAY | NC | SE(E23=E22;"NC";E23) |
| REC | REC | SE(E24=E23;"NC";E24) |
| PLAY | PLAY | SE(E25=E24;"NC";E25) |
| REC | REC | SE(E26=E25;"NC";E26) |
| REC | NC | SE(E27=E26;"NC";E27) |
7 Replies
- parry2k
Super User
Here is something which can get you started:
I assume there is index column in your table, if not you can add one using "Edit Query", "Add Column", once it is added, you can create calculated column using following formula:
Column = var prevKind = CALCULATE(MAX(Table1[KIND]), FILTER(Table1,Table1[Index]= EARLIER(Table1[Index])-1)) return if(Table1[KIND]=prevkind, "NC", Table1[Kind])
- RPaschoaliniFrequent Visitor
The function MAX takes an argument that evaluates to numbers or dates and cannot work with values of type String.
- parry2k
Super User
Do you have unique key field like index in my example which is number and that is required for earlier. If not, as suggested, add a custom index column using edit query.