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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jlam
Frequent Visitor

Current Month Number DAX Formula for Current and Previous Year Sales

Hello everyone,

 

For my Power BI Desktop file, I am using Connx tables through a odbc connction. Sales for every year are stored in separate tables. For example, the 2018 table is labelled as DTYYMM2018, 2017 is labelled as DTYYMM2017. I have a Date table with a relationship to my Sales tables. 

 

The users have requested to have the current month sales in one visual and they would like to see the same month in the previous year in one visual (ex. June 2018 sales with June 2017 sales). Please see the following screenshot for the visualization.

 

1.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I have placed a visual level filter with the month number but the issue is that every month, I need to select the next month number manually and there are over 40 reports. I have found a DAX formula which can identify current month. 

 

 

CurrentMonth 2018 =
IF (YEAR (DTLMMY2018[InvoiceDate]) = YEAR ( TODAY () )
&& MONTH ( DTLMMY2018[InvoiceDate]) = MONTH ( TODAY () ),
"Yes",
"No") 

 

This formula works well for the current year but does not allow me to show the previous year and same month in a single visualization. Please see the following screenshot with the formula applied. It will show that current month sales and teh whole year sales from the previous year.

 

2.png

 

 

 

 

 

 

 

 

 

 

 

 

 

               

 

 

 

Can anyone advise a DAX formula which can provide the current month number that can be applied for any year as opposed to only the current year?

 

Thank you,

Jessica

1 REPLY 1
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi Jessica,

 

What are the formulas you used? I would suggest you use a slicer in "Relative" mode and use the "SAMEPERIODLASTYEAR" in the formula. 

Current_Month_Number_DAX_Formula_for_Current_and_Previous_Year_Sales

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors
Top Kudoed Authors