Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

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 column "Status" would say: Same, Changed, None

Thanks a lot!! Rosario Pineda.

IDYearActivity
12019Yoga
12019Dance
12019Pilates
12019Swimming
12020Dance
12020Pilates
12020Swimming
12020Meditation
22019Yoga
22019Dance
22019Pilates
22019Swimming
22020Yoga
22020Dance
22020Pilates
22020Swimming
32019Yoga
32019Dance
32019Pilates
32019Swimming
32020Yoga
32020Dance
32020
32020Swimming
2 ACCEPTED SOLUTIONS

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





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

Proud to be a Super User!




View solution in original post

@ryan_mayu thank you very much for your support, I work percfecto!!

Greetings and blessings. Rosary.

View solution in original post

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft 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"
)
 
Pat
 




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


ryan_mayu
Super User
Super User

@Syndicate_Admin 

i can't find id year and activity has the same value. 

could you pls add the expected output in the sample data you provided?





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

Proud to be a Super User!




Sorry I didn't understand your question, I rewuiero new column as the example below:

Rosario_0-1661821183814.png

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





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

Proud to be a Super User!




@ryan_mayu thank you very much for your support, I work percfecto!!

Greetings and blessings. Rosary.

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.