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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
char23
Helper II
Helper II

How to lookup and compare data in the same table

Hello, I need help with adding a new column. Is there a way to lookup values/compare data in the same table? I have schedule data that will be added to the table for each month. Most values in the ID column will repeat each month, and there will be some IDs that are removed or added. I am trying to add a new column to the same table that shows the status of the previous month. Columns Status and Schedule Status are calculated columns with Dax. Any help to put me in the right directions is useful. 

 

 

 

ID

StatusSchedule StatusPrevious Status
ABCOn timePrevious 
DEFNot on TimePrevious 
GHIFuturePrevious 
JKLOn timePrevious 
ABCOn timeCurrentOn time
DEFOn timeCurrentNot on Time
GHIOn timeCurrentFuture
JKLOn timeCurrentOn time
MNOOn timeCurrentAdded
1 ACCEPTED SOLUTION
samratpbi
Super User
Super User

Hi, I created the below table:

samratpbi_0-1721337443424.png

Then created the below measure:

Prev Status =
VAR _selectedID = SELECTEDVALUE(PreviousStat[ID])
VAR _preVal =
CALCULATE
(
    MIN(PreviousStat[Schedule Status]),
    PreviousStat[ID] = _selectedID,
    ALLEXCEPT(PreviousStat, PreviousStat[Previous Status]),
    PreviousStat[Previous Status] <> "Current"        
)
RETURN
IF(
    SELECTEDVALUE(PreviousStat[Previous Status]) <> "Current",
    "",
    IF(
        ISBLANK(_preVal), "Added",
        _preVal
    )
)
And the output:
samratpbi_1-1721337759210.png

If this helps to resolve your problem, then please mark it as solution! Thanks

Dont forget to give Kudos 🙂

 

View solution in original post

2 REPLIES 2
samratpbi
Super User
Super User

Hi, I created the below table:

samratpbi_0-1721337443424.png

Then created the below measure:

Prev Status =
VAR _selectedID = SELECTEDVALUE(PreviousStat[ID])
VAR _preVal =
CALCULATE
(
    MIN(PreviousStat[Schedule Status]),
    PreviousStat[ID] = _selectedID,
    ALLEXCEPT(PreviousStat, PreviousStat[Previous Status]),
    PreviousStat[Previous Status] <> "Current"        
)
RETURN
IF(
    SELECTEDVALUE(PreviousStat[Previous Status]) <> "Current",
    "",
    IF(
        ISBLANK(_preVal), "Added",
        _preVal
    )
)
And the output:
samratpbi_1-1721337759210.png

If this helps to resolve your problem, then please mark it as solution! Thanks

Dont forget to give Kudos 🙂

 

Thank you for sending this. This seems to help a lot! However I am trying to alter this for my data and should have provided more details initially. My [Previous Status] column is actually a series of numbers where 1 = current, 2= previous, and >2 = old data that I want to ignore. I've tried altering your formula similar to what is below (red text below table), but I keep getting "Added" for every record in the new column. I want to add the column in green. Also, will eventually have to add to show deleted records (May need another column for this, i'm not sure) 

 

IDSchedule StatusPrevious StatusPrev Status (from Previous status =2) 
ABCNot Started3 
DEFNot Started3 
GHINot Started3 
JKLNot Started3 
ABCOn time 2 
DEFNot on Time2Deleted (Not found from Previous status =1)
GHIFuture2 
JKLOn time 2 
ABCOn time 1On time
GHIOn time 1Future
JKLOn time 1On time
MNOOn time 1Added

 

Prev Status =
VAR _selectedID = SELECTEDVALUE(PreviousStat[ID])
VAR _preVal =
CALCULATE
(
    MIN(PreviousStat[Schedule Status]),
    PreviousStat[ID] = _selectedID,
    ALLEXCEPT(PreviousStat, PreviousStat[Previous Status]),
    PreviousStat[Previous Status] = 2        
)
RETURN
IF(
    SELECTEDVALUE(PreviousStat[Previous Status]) > 1,
    "",
    IF(
        ISBLANK(_preVal), "Added",
        _preVal
    )
)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.