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
Anonymous
2 years agoNot applicable
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