Forum Discussion
Calculate Flag based on conditions
- Anonymous3 years ago
Hi sfernamer ,
By nature, columns created in power bi desktop cannot be used in power query.
We can create a column.
_FastBreak_TOV = var a=ADDCOLUMNS('Table',"flag1s",IF('Table'[Final Result]="Turnover",1,0),"flag2s",IF('Table'[Situation]="FastBreak",1,0)) var b=ADDCOLUMNS(a,"flag3s",MAXX(FILTER(a,[Índice]=EARLIER('Table'[Índice])+1),[flag1s])) var c=FILTER(b,[Índice]=EARLIER('Table'[Índice])) return IF(MAXX(c,[flag2s])*MAXX(c,[flag3s])=1,1,0)If you do not want to remove the extra calculated columns, you can use the SELECTCOLUMNS function to create a table containing the columns you need.
Table 2 = SELECTCOLUMNS('Table',"indice",'Table'[Índice],"sit",'Table'[Situation],"final",'Table'[Final Result],"tov",'Table'[FastBreak_TOV])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 sfernamer ,
By nature, columns created in power bi desktop cannot be used in power query.
We can create a column.
_FastBreak_TOV = var a=ADDCOLUMNS('Table',"flag1s",IF('Table'[Final Result]="Turnover",1,0),"flag2s",IF('Table'[Situation]="FastBreak",1,0))
var b=ADDCOLUMNS(a,"flag3s",MAXX(FILTER(a,[Índice]=EARLIER('Table'[Índice])+1),[flag1s]))
var c=FILTER(b,[Índice]=EARLIER('Table'[Índice]))
return IF(MAXX(c,[flag2s])*MAXX(c,[flag3s])=1,1,0)
If you do not want to remove the extra calculated columns, you can use the SELECTCOLUMNS function to create a table containing the columns you need.
Table 2 = SELECTCOLUMNS('Table',"indice",'Table'[Índice],"sit",'Table'[Situation],"final",'Table'[Final Result],"tov",'Table'[FastBreak_TOV])
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.
- sfernamer3 years ago
Helper III
Hi Anonymous
Thank you for your time. This last solution worked perfectly (and only adding one column). Thta was perfect!
Thank you again. 🙂