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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ADSL
Post Prodigy
Post Prodigy

Calculate & Comparison Current Week of Month with Last Month of Week

Hi BI Community Team,

 

I have a sales order table that contain data 02 months - Nov'23 & Dec'23. With this data, I am standing in Dec'23 by week then want to see and compare with last month by week as the screenshot below. 

 

Example:  W1-Dec vs W1-Nov | W2-Dec vs W2-Nov

 

Any suggestion/advise? 

 

2023-12-08_16-11-47.jpg

1 ACCEPTED SOLUTION

Considering you'll need to calculate the last month, I think we should use month number in the measure.

I've also modified the measure a little bit as below.

 

Total Sales Same Week Last Month2 = 
VAR _SameWeek = SELECTEDVALUE('Calendar'[Week of Month])
VAR _LastMonth = IF(SELECTEDVALUE('Calendar'[MonthOfYear])= 1, 12, SELECTEDVALUE('Calendar'[MonthOfYear]) -1)
VAR _LastMonthYear = IF(SELECTEDVALUE('Calendar'[MonthOfYear])= 1, SELECTEDVALUE('Calendar'[Year])-1, SELECTEDVALUE('Calendar'[Year]))
RETURN 
IF( CALCULATE( SUM('Sales Order'[Amt No VAT]), 'Calendar'[Week of Month] = _SameWeek) >0,
CALCULATE( SUM('Sales Order'[Amt No VAT]), FILTER(ALL('Calendar'), 'Calendar'[Week of Month] = _SameWeek && 'Calendar'[MonthOfYear] = _LastMonth && 'Calendar'[Year] = _LastMonthYear)),
BLANK())

 

Best Regards,

Joyce

View solution in original post

6 REPLIES 6
mh2587
Super User
Super User

WoW Sales Comparison = //Try this one might help you
VAR CurrentFirstWeekSale =
    CALCULATE ( [Total Sales], 'Calendar'[WeekNumber of Month] = 1 )
VAR PreviouseFirstWeekSale =
    CALCULATE (
        [Total Sales],
        DATEADD ( 'Calendar'[Date], -1, MONTH ),
        'Calendar'[WeekNumber of Month] = 1
    )
RETURN
    CurrentFirstWeekSale - PreviouseFirstWeekSale

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



isjoycewang
Solution Supplier
Solution Supplier

Hi @ADSL,

 

Please see attached demo file here.

You can create another measure and add it into the clustered column chart as below.

Total Sales Same Week Last Month = 
VAR _week = SELECTEDVALUE('Calendar'[Week of Month])
VAR _month = SELECTEDVALUE('Calendar'[Date].[MonthNo])
RETURN 
CALCULATE( SUM('Sales Order'[Amt No VAT]), FILTER(ALL('Calendar'), 'Calendar'[Week of Month] = _week && 'Calendar'[Date].[MonthNo] = _month-1))

 

If you only want to see Nov data when you have Dec data:

Total Sales Same Week Last Month = 
VAR _week = SELECTEDVALUE('Calendar'[Week of Month])
VAR _month = SELECTEDVALUE('Calendar'[Date].[MonthNo])
RETURN 
IF( CALCULATE( SUM('Sales Order'[Amt No VAT]), 'Calendar'[Week of Month] = _week) >0,
CALCULATE( SUM('Sales Order'[Amt No VAT]), FILTER(ALL('Calendar'), 'Calendar'[Week of Month] = _week && 'Calendar'[Date].[MonthNo] = _month-1)),
BLANK())

 

isjoycewang_0-1702029342452.png

 

Best Regards,

Joyce

 

Hi @isjoycewang,

 

Thank you for your helpful feedback. 

 

If we want to change the slicer of month to "MonthInCalendar" as the screenshot below.

 

Any suggestion to revise the measure?

 

2023-12-13_09-08-20.jpg

 

Best Regards,

Considering you'll need to calculate the last month, I think we should use month number in the measure.

I've also modified the measure a little bit as below.

 

Total Sales Same Week Last Month2 = 
VAR _SameWeek = SELECTEDVALUE('Calendar'[Week of Month])
VAR _LastMonth = IF(SELECTEDVALUE('Calendar'[MonthOfYear])= 1, 12, SELECTEDVALUE('Calendar'[MonthOfYear]) -1)
VAR _LastMonthYear = IF(SELECTEDVALUE('Calendar'[MonthOfYear])= 1, SELECTEDVALUE('Calendar'[Year])-1, SELECTEDVALUE('Calendar'[Year]))
RETURN 
IF( CALCULATE( SUM('Sales Order'[Amt No VAT]), 'Calendar'[Week of Month] = _SameWeek) >0,
CALCULATE( SUM('Sales Order'[Amt No VAT]), FILTER(ALL('Calendar'), 'Calendar'[Week of Month] = _SameWeek && 'Calendar'[MonthOfYear] = _LastMonth && 'Calendar'[Year] = _LastMonthYear)),
BLANK())

 

Best Regards,

Joyce

Hi @isjoycewang,

 

Thank you for your valuable feebback and helup. 

 

All your measure are working, just want to change the slicer of month to choose month & year.

 

Best Regards,

Glad to help!

The measure should work whether you use [MonthNo] or [MonthInCalendar] in the slicer.

Since the first month in a year might cause BLANK in the chart, provided above updated measure for your reference.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.