Forum Discussion
Syndicate_Admin
3 years agoAdministrator
Create new conditional column
Hello, can someone please help me with DAX? I want to create a fourth column called "Satatus" where I indicate if the "ID", "Year", "activity" had the same activity. Then the result in the new colum...
- 3 years ago
you can try this
Column = VAR _a=maxx(FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Year]<>EARLIER('Table'[Year])&&'Table'[Activity]=EARLIER('Table'[Activity])),'Table'[Activity]) return if('Table'[Activity]="","Ninguna",if(_a="","Cambiaron","Misma"))pls see the attachment below
- 3 years ago
@ryan_mayu thank you very much for your support, I work percfecto!!
Greetings and blessings. Rosary.
mahoneypat
3 years agoMicrosoft Employee
Not sure this is what you mean, but please try this column expression. Replace Activities with your actual table name.
NewColumn =
VAR thisactivity = Activities[Activity]
VAR thisyear = Activities[Year]
VAR PYactivities =
CALCULATETABLE (
DISTINCT ( Activities[Activity] ),
ALLEXCEPT ( Activities, Activities[ID] ),
Activities[Year] = thisyear - 1
)
RETURN
SWITCH (
TRUE (),
ISEMPTY ( PYactivities ), "None",
thisactivity IN PYactivities, "Same",
"Change"
)
VAR thisactivity = Activities[Activity]
VAR thisyear = Activities[Year]
VAR PYactivities =
CALCULATETABLE (
DISTINCT ( Activities[Activity] ),
ALLEXCEPT ( Activities, Activities[ID] ),
Activities[Year] = thisyear - 1
)
RETURN
SWITCH (
TRUE (),
ISEMPTY ( PYactivities ), "None",
thisactivity IN PYactivities, "Same",
"Change"
)
Pat