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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Krishna_Newuser
Helper II
Helper II

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
Krishna_Newuser
Helper II
Helper II

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
Krishna_Newuser
Helper II
Helper II

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.