Forum Discussion
carolinesb
2 years agoRegular Visitor
Power bi dax - TABLE
Hello, can anyone help me with the dax formula? I need it to be classified this way: not_buy = If you have SALE VALUE filled in in the year 2023 return "prospect" The name of the table is Sa...
- Anonymous2 years ago
Hi carolinesb ,
Here are the steps you can follow:
1. Create calculated column.
Test1 = var _column= SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])&&[sales value]<>BLANK()),"Year",[Year]) var _discount= CALCULATE( DISTINCTCOUNT('Table'[Year]), FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])&&[sales value]<>BLANK())) return SWITCH( TRUE(), 2023 in _column && 2024 in _column,"repurchased", NOT(2023) in _column && 2024 in _column && _discount>1,"new",BLANK())Test2 = var _column= SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])&&[sales value]<>BLANK()),"Year",[Year]) return IF( 2023 in _column,"prospect")2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Ritaf1983
Super User
2 years agoHi carolinesb
Take a look at new and repeat customer analysis patterns at the linked blog posts:
https://blog.finance-bi.com/power-bi-new-and-repeat-customers/
https://www.daxpatterns.com/new-and-returning-customers/
and video tutorial:
https://www.youtube.com/watch?v=WCt5IFsPUCA
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
carolinesb
2 years agoRegular Visitor
The dax IF('Vendas', Ano[Ano], "prospectar",0) are correct?