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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
griffinst
Frequent Visitor

Lookup previous month value

I need to create 2 columns.  One that shows the Prior Month FCST value from the same project and another that shows if the "Status" changed on that project.

 

 

FCST DateStatusProjectFCSTPrior MonthStatus Change from Prior Month
1/1/2024In-ForecastAlpha100  
1/1/2024In-ForecastGamma200  
1/1/2024In-IdeationSigma300  
2/1/2024In-ForecastAlpha400100F
2/1/2024In-ForecastGamma500200F
2/1/2024In-ForecastSigma600300T
3/1/2024In-ForecastAlpha700400F
3/1/2024In-ForecastGamma800500F
3/1/2024In-ForecastSigma900600F
2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@griffinst 

pls try this

 

Column = MAXX(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[FCST Date]=EDATE(EARLIER('Table'[FCST Date]),-1)),'Table'[FCST])
 
Column 2 =
VAR _status=MAXX(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[FCST Date]=EDATE(EARLIER('Table'[FCST Date]),-1)),'Table'[Status])
return if(_status="","",if(_status='Table'[Status],"F","T"))
 
11.PNG

 





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

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

Hi @griffinst 

 

Maybe you can try this:

Here I create 2 calculated columns:

_Prior Month =
CALCULATE (
    SUM ( 'Table'[FCST] ),
    ALLSELECTED ( 'Table' ),
    'Table'[Project] = EARLIER ( 'Table'[Project] ),
    DATEADD ( 'Table'[FCST Date], -1, MONTH )
)
_Status Change? =
VAR _priorStatus =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Status] ),
        ALLSELECTED ( 'Table' ),
        'Table'[Project] = EARLIER ( 'Table'[Project] ),
        DATEADD ( 'Table'[FCST Date], -1, MONTH )
    )
RETURN
    IF ( _priorStatus <> BLANK (), IF ( 'Table'[Status] = _priorStatus, "F", "T" ) )

The result is as follow:

vzhengdxumsft_0-1727147619664.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @griffinst 

 

Maybe you can try this:

Here I create 2 calculated columns:

_Prior Month =
CALCULATE (
    SUM ( 'Table'[FCST] ),
    ALLSELECTED ( 'Table' ),
    'Table'[Project] = EARLIER ( 'Table'[Project] ),
    DATEADD ( 'Table'[FCST Date], -1, MONTH )
)
_Status Change? =
VAR _priorStatus =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Status] ),
        ALLSELECTED ( 'Table' ),
        'Table'[Project] = EARLIER ( 'Table'[Project] ),
        DATEADD ( 'Table'[FCST Date], -1, MONTH )
    )
RETURN
    IF ( _priorStatus <> BLANK (), IF ( 'Table'[Status] = _priorStatus, "F", "T" ) )

The result is as follow:

vzhengdxumsft_0-1727147619664.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I got the Prior Month working.  Thank you very much.  I had to add the Business Area and LOB to the formula as it needs to match the "Project", "Business Area", and "LOB" of the prior month.

 

Prior Month =
CALCULATE (
    SUM ( 'MOM'[Forecast] ),
    ALLSELECTED ( 'MOM' ),
    'MOM'[Project] = EARLIER ( 'MOM'[Project] ),
    'MOM'[Business Area] = EARLIER ( 'MOM'[Business Area] ),
    'MOM'[LOB] = EARLIER ( 'MOM'[LOB] ),
    DATEADD ( 'MOM'[FCST Date], -1, MONTH )
)

 

For the Status Change though I added the same for Business Area and LOB but it is not working as expected.

 

Status Change =
VAR _priorStatus =
    CALCULATE (
        SELECTEDVALUE ( 'MOM'[Project Status] ),
        ALLSELECTED ( 'MOM' ),
        'MOM'[Project] = EARLIER ( MOM[Project] ),
        'MOM'[Business Area] = EARLIER ( MOM[Business Area] ),
        'MOM'[LOB] = EARLIER ( MOM[LOB] ),

        DATEADD ( 'MOM'[FCST Date], -1, MONTH )
    )
RETURN
    IF ( _priorStatus <> BLANK (), IF ( 'MOM'[Affordability of Care Initiatives] = _priorStatus, "F", "T" ) )
ryan_mayu
Super User
Super User

@griffinst 

pls try this

 

Column = MAXX(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[FCST Date]=EDATE(EARLIER('Table'[FCST Date]),-1)),'Table'[FCST])
 
Column 2 =
VAR _status=MAXX(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[FCST Date]=EDATE(EARLIER('Table'[FCST Date]),-1)),'Table'[Status])
return if(_status="","",if(_status='Table'[Status],"F","T"))
 
11.PNG

 





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

Proud to be a Super User!




I got it working with a combination from both of you.  thank you very much.

you are welcome





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

Proud to be a Super User!




SamWiseOwl
Super User
Super User

Hi @griffinst 

You can create a measure using DATEADD to move the values:

Last month =
CALCULATE(
    sum('Status'[FCST])
    ,ALLSELECTED('Status'[Status]) --remove status filter
    ,DATEADD('Status'[FCST Date],-1, MONTH) --move back 1 month
)
 
What do you want to return if it has changed?
At a guess it would be:
Status Last month =
var currStatus = SELECTEDVALUE('Status'[Status])
var lastStatus =
CALCULATE(
   SELECTEDVALUE('Status'[Status])
  ,ALLSELECTED('Status'[Status]) --remove status filter
    ,DATEADD('Status'[FCST Date],-1, MONTH) --move back 1 month
)
RETURN
if(
    currStatus <> lastStatus && lastStatus <> BLANK()
    ,"T"
    ,"F"
)

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

This did not work for the Status Change "T" or "F" column.  It's showing "F" for everything even though I change one of the status'.

 

Status Last month =
var currStatus = SELECTEDVALUE('Status'[Status])
var lastStatus =
CALCULATE(
   SELECTEDVALUE('Status'[Status])
  ,ALLSELECTED('Status'[Status]) --remove status filter
    ,DATEADD('Status'[FCST Date],-1MONTH--move back 1 month
)
RETURN
if(
    currStatus <> lastStatus && lastStatus <> BLANK()
    ,"T"
    ,"F"
)
 
The first Measure you suggested for the "Prior Month FCST" does not work.  I just want the value from the prior month from the FCST column where the "Project" matches of course.

I need these to be columns not measures.

@griffinst  Edited to included Status change T or F


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.