web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Compare January This Y...
Power Apps
Answered

Compare January This Year to December Last Year

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

 

Happy New Year!

So I had written a filter formula that filters data based on the result of a comparison between the number of the current month and that of last month.

This is an excerpt of my formula...

 

Filter(
 colVoucherReportTable,
 Switch(
 dpd_Reports_PeriodOptions.Selected.Value,
 "This Week",
 WeekNum(Created) = WeekNum(Today()),
 "Last Week",
 WeekNum(Created) = WeekNum(Today() - 7),
 "This Month",
 Month(Created) = Month(Today()),
 "Last Month",
 Month(Created) = Month(Today()) - 1,
 "This Quarter",
 RoundUp(
 Month(Created / 3),
 0
 ) = RoundUp(
 Month(Today()) / 3,
 0
 ),
 "Last Quarter",
 RoundUp(
 Month(Created / 3),
 0
 ) = RoundUp(
 Month(Today()) / 3,
 0
 ) - 1,
 "Specific Period",
 Created >= dpc_Reports_StartDate.SelectedDate && Created <= dpc_Reports_EndDate.SelectedDate + 1
 );

 

 

My problem now is that everything that is based on the Month() function returns blank.

If we look at Month(Created) = Month(Today()) - 1 for example, Month(Created) = 12 and Month(Today()) - 1 = 0 where I'm expecting 12. This worked fine last year, but obviously not in 2024 because we're in January (month 1). How can I solve this problem?

The filter based on WeekNum() seems fine. I hope there are no future problems there that I haven't discovered yet...Thank you.

Categories:
  • Verified answer
    lbendlin Profile Picture
    8,726 Super User 2026 Season 1 on at

    You need a yearmonth number that is year*12+month.  Then you can subtract 1 from that to always get the previous yearmonth regardless of year switchovers.

  • AdaEloka Profile Picture
    on at

    Thank you @lbendlin, but I don't understand. How will the syntax look like?

  • AdaEloka Profile Picture
    on at

    Hi @lbendlin I figured it out....Year(Created)*12+Month(Created) = Year(Today())*12+Month(Today())-1. Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard