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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
N4gash
Frequent Visitor

Previous month value of text column

Hey!

I'm struggling with Power BI to show a table with the Score of the current month and previous month.

 

My test dataset is the following:

PeriodValueScore
31/08/2022ANoFav
31/08/2022BNeutral
31/08/2022CNeutral
31/08/2022DNeutral
30/09/2022AFav
30/09/2022BNoFav
30/09/2022CFav
30/09/2022DNoFav
31/10/2022AFav
31/10/2022BFav
31/10/2022CFav
31/10/2022DNoFav

 

And what I want to achieve is:

ValuePeriodScoreScorePreviousMonth
A31/08/2022NoFav 
A30/09/2022FavNofav
A31/10/2022FavFav
B31/08/2022Neutral 
B30/09/2022NoFavNeutral
B31/10/2022FavNoFav

 

To calculate the column ScorePreviousMonth i'm trying with this DAX formula, but it doesn't work and shows blanks instead the values:

 

ScorePreviousMonth = 
MAXX(
    FILTER ( ALL('table'), 'table'[Period] =  (DATEADD('table'[Period], -1, MONTH ))  )
    , 'table'[Score]
    )

 

 

I've created a Calendar table and tried as well, but with the same result.

 

ScorePreviousMonth = 
MAXX(
    FILTER ( ALL('table'), 'table'[Period] =  PREVIOUSMONTH('Calendar'[Date]  ))
    , 'table'[Score]
    )

 

 

2023-01-20 13_14_05-test - Power BI Desktop.png

 

 

Any idea?

 

Thanks in advance,

Regards

1 ACCEPTED SOLUTION
DimaMD
Solution Sage
Solution Sage

Hi @N4gash  Try it colum

 

colum = 
VAR _max = PREVIOUSMONTH('table'[Period])
return
MAXX(
FILTER ( 
    ALL('table'), 
    EOMONTH('table'[Period],0) = _max 
    && 'Table'[Value] = EARLIER([Value])
    )
, 'table'[Score]
) 

Screenshot_30.jpg

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

View solution in original post

5 REPLIES 5
DimaMD
Solution Sage
Solution Sage

Hi @N4gash  Try it colum

 

colum = 
VAR _max = PREVIOUSMONTH('table'[Period])
return
MAXX(
FILTER ( 
    ALL('table'), 
    EOMONTH('table'[Period],0) = _max 
    && 'Table'[Value] = EARLIER([Value])
    )
, 'table'[Score]
) 

Screenshot_30.jpg

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

@DimaMD , Thank you for your easy to read example. Much appreciated!

N4gash
Frequent Visitor

Awesome @DimaMD  it works!! 

 

Thanks

N4gash
Frequent Visitor

Thanks @amitchandak !!

 

I've tried your formula (adding "_max" to the filter) but the result is still wrong, it seems that uses the max Score for each Period -> NoFav at 31/08/2022 and 31/10/2022:

 

 

New col = 
var _max = eomonth('table'[Period],-1)
return
MAXX(
FILTER ( 'table', Eomonth('table'[Period],0) = _max)
, 'table'[Score]
) 

 

 

 2023-01-20 13_14_05-test - Power BI Desktop.png

 

If I try with MINX instead MAXX:

N4gash_0-1674218685778.png

 

How can I applied the MAXX for each row?

 

amitchandak
Super User
Super User

@N4gash , if you need a column

 

New col
=
var _max = eomonth('table'[Period],-1)
return
MAXX(
FILTER ( 'table', Eomonth('table'[Period],0) = )
, 'table'[Score]

 

for mesure try TI with date table

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.