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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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 Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors