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
Anonymous
Not applicable

Last Month In Card Visual

Hello,

I need to calculate the previous month data(April) for this year to be shown in CARD visual.  Data has the value since last year May (2023) to till date. When I try few measures it throws 0% and blank values. And when I use other dax function, its providing Average from Jan to May 2024 value. Request your help on this.


Note: I have the calendar table which I created for fiscal year, Quarter, Month Name, Month separately. And whenever the month changes(from May to June), it has to show the next previous month(May) month value. 

 

Used Measures:

Check=

var Month_ = Month(TODAY())

VAR last_rows = CALCULATE(COUNTROWS('Adoption Trend_Dup'), FILTER('Adoption Trend_Dup', 'Adoption Trend_Dup'[Month] = (Month_ - 1)))

VAR last_adop = CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER('Adoption Trend_Dup', 'Adoption Trend_Dup'[Month] = (Month_ - 1)))

var result = DIVIDE(last_adop, last_rows)

RETURN

IF(Month_ = 1, BLANK(), FORMAT(result, "0%"))

 

Previous Month =

CALCULATE('Adoption Trend_Dup'[AdoptionTrend%], PREVIOUSMONTH('Adoption Trend_Dup'[TxnDt])

)

 

Previous Month =

CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]),DATESBETWEEN('Calendar Table'[Dates], EOMONTH(TODAY(),-14)+1, EOMONTH(TODAY(),-13)))

 

Previous Month =

CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]),

YEAR('Calendar Table'[Dates]) = YEAR(TODAY()),

Month('Calendar Table'[Dates] = MONTH(TODAY()-1)))

 

Data Examples:

 

Store IdStore NameNewAdoptionTxnDt
1AA0%Sunday, May 5, 2024
2BB80%Sunday, May 5, 2024
3CC82%Sunday, May 5, 2024
4DD56%Sunday, May 5, 2024
10BBB0%Sunday, May 5, 2024
11AAA78%Sunday, May 5, 2024
12AAAA28%Sunday, May 5, 2024
13AAAAA16%Sunday, May 5, 2024
14BBBBB2%Sunday, May 5, 2024
1AA0%Monday, April 1, 2024
2BB80%Monday, April 1, 2024
3CC82%Monday, April 1, 2024
4DD56%Monday, April 1, 2024
5EE92%Monday, April 1, 2024
6FF0%Monday, April 8, 2024
7GG6%Monday, April 8, 2024
8HHH0%Monday, April 8, 2024
12AAAA28%Monday, April 15, 2024
13AAAAA16%Monday, April 15, 2024
14BBBBB14%Monday, April 15, 2024
1AA0%Monday, January 1, 2024
2BB80%Monday, January 8, 2024
3CC82%Wednesday, January 10, 2024
4DD56%Sunday, January 21, 2024
5EE92%Thursday, February 1, 2024
6FF0%Thursday, February 8, 2024
7GG6%Sunday, February 11, 2024
8HHH51%Tuesday, February 13, 2024
9AAA39%Friday, March 1, 2024
10BBB0%Saturday, March 2, 2024
11AAA78%Sunday, March 3, 2024
12AAAA28%Monday, March 4, 2024
13AAAAA16%Tuesday, March 5, 2024
14BBBBB14%Wednesday, March 6, 2024
1AA0%Saturday, April 1, 2023
2BB23%Sunday, April 2, 2023
3CC43%Monday, April 3, 2023
1AA66%Monday, May 1, 2023
2BB77%Tuesday, May 2, 2023
3CC0%Wednesday, May 3, 2023
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

You can ignore this message, i got one dax from @amitchandak, its working effectively. Thank you so much.

Previous Month =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
RETURN
CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER(ALL('Calendar Table'), 'Calendar Table'[Dates] >= _min && 'Calendar Table'[Dates] <=_max ) )
 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi,

You can ignore this message, i got one dax from @amitchandak, its working effectively. Thank you so much.

Previous Month =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1) //today()
RETURN
CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER(ALL('Calendar Table'), 'Calendar Table'[Dates] >= _min && 'Calendar Table'[Dates] <=_max ) )
 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.