cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RPaschoalini Frequent Visitor
Frequent Visitor

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

 

TIPOCOLUNA CALCULADAFORMULA
RECRECSE(E20=E19;"NC";E20)
RECNCSE(E21=E20;"NC";E21)
PLAYPLAYSE(E22=E21;"NC";E22)
PLAYNCSE(E23=E22;"NC";E23)
RECRECSE(E24=E23;"NC";E24)
PLAYPLAYSE(E25=E24;"NC";E25)
RECRECSE(E26=E25;"NC";E26)
RECNCSE(E27=E26;"NC";E27)
7 REPLIES 7
Super User
Super User

Re: DAX IF EARLIER

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])





Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





RPaschoalini Frequent Visitor
Frequent Visitor

Re: DAX IF EARLIER

The function MAX takes an argument that evaluates to numbers or dates and cannot work with values of type String.

Super User
Super User

Re: DAX IF EARLIER

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.






Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





RPaschoalini Frequent Visitor
Frequent Visitor

Re: DAX IF EARLIER

Capturar.PNG

Super User
Super User

Re: DAX IF EARLIER

what is your data source? Also are you using lates March release of Power BI Desktop






Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





RPaschoalini Frequent Visitor
Frequent Visitor

Re: DAX IF EARLIER

Data source: excel .xlsx

Version: 2.35.4399.601 32-bit (maio de 2016)

Super User
Super User

Re: DAX IF EARLIER

First and foremost, can you update your PowerBI to latest release which is Version: 2.44.4675.422 64-bit (March, 2017)






Did I answer your question? Mark my post as a solution.

Proud to be a Datanaut! Appreciate your Kudos Smiley Happy
Feel free to email me with any of your BI needs.





Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 294 members 3,110 guests
Please welcome our newest community members: