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
Junaid11
Helper V
Helper V

Compare text value with previous month

Hello,
I want to compare Code which is Text with previous month. Each code can come is unique like in January this code can only comes one not more than that. Same code can come in next month but it can only come only once there as well. 
My tale looks like below:

MonthCode
March112
March123
April866
April112
May656
May234

I want to create a new column and comapre these codes with previous month. If For example code 112 in April is also in previous month then the value against it should be like unchanged. If the codeis not in previous month then it should show new else it should show gone. I am attaching a outcome table as well along with the criteria.

MonthCodeOutcome
March112GONE
March123GONE
April866NEW
April112UNCHANGED
May656NEW
May234NEW

If Exist in March and April: 'Unchanged'
If Exist in March Not Exist April: 'Gone'
if don't exist in march and exist in April: 'New"
It would be highly appreciated if I can get the response.
Thank you

2 REPLIES 2
amitchandak
Super User
Super User

@Junaid11 , Try like

 

New column =
var _date = [Date]
var _code = maxx(filter(Table,eomonth(_date,0) = eomonth([Date],0) ),[Code])
return
Switch(True(),

[Code] = _code, "Unchanged",

Not(isblank(_code)) && [Code]<> _code, "New" , "Gone")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak ,

The code is not working I am getting below outcome which is not similar to outocme I have mentioned.

asfeferfrrr.PNG

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