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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ADSL
Post Prodigy
Post Prodigy

Not Showing the Total Sales of Last Week (Last Month)

Hi BI Community Team,

 

I have table of sales order, customer & supplier and looking for weekly sales comparion between current & last month. After applied the measure, grand total of last week (last month) doesn't show as the screenshot below.

 

2024-12-01_07-41-37.jpg

 

Any suggestion & advise of this issue?

 

Thanks and Regards,

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

 

looking for weekly sales comparion between current & last month

 

weeks and months are incompatible.

 

Best you can do is date math like so

 

Last Week Sales (PM) = CALCULATE([MTD Sales],DATEADD('Calendar'[Date],-7,DAY))
 
(whatever MTD means to you - you should use the Calendar Date for this.)

View solution in original post

4 REPLIES 4
ADSL
Post Prodigy
Post Prodigy

Hi All,

 

Thank you for your helpful feedback and advise.

 

Best Regards,

Anonymous
Not applicable

Hi @ADSL 

 

Thank you very much rajendraongole1 and lbendlin   for your prompt reply.

 

I made some modifications to your code, as follows:

 

Last Week Sales (PM) = 
VAR _week = SELECTEDVALUE('Calendar'[Week of Month])
VAR _month = SELECTEDVALUE('Calendar'[Date].[MonthNo])
VAR _year = SELECTEDVALUE('Calendar'[Date].[Year])
VAR _isTotal = ISINSCOPE('Calendar'[Week of Month]) = FALSE()
RETURN
IF(
    _isTotal,
    CALCULATE(
        SUM('Sales Order'[Amt]), 
        FILTER(
            ALL('Calendar'), 
            YEAR('Calendar'[Date]) = _year 
            && 
            MONTH('Calendar'[Date]) = _month-1
        )
    ),
    CALCULATE(
        SUM('Sales Order'[Amt]), 
        FILTER(
            ALL('Calendar'), 
            YEAR('Calendar'[Date]) = _year 
            && 
            'Calendar'[Week of Month] = _week 
            && 
            MONTH('Calendar'[Date]) = _month-1
        )
    )
)
 

 

Here is the result.

 

vnuocmsft_0-1733120042861.png

 

Regards,

Nono Chen

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

 

rajendraongole1
Super User
Super User

Hi @ADSL - you can try the below suggested solution from @lbendlin 

adding another workaround, Your measure for "Last Week" likely calculates values per week, but at the total level, it might not aggregate correctly. 

LastWeekSales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATEADD(Sales[Date], -7, DAY)
)

 

To ensure correct totals, use ISINSCOPE to distinguish between row-level and total-level calculations.

LastWeekSales =
IF(
ISINSCOPE(Sales[Customer]),
CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -7, DAY)),
SUMX(
VALUES(Sales[Week]),
CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -7, DAY))
)
)

 

There should be a Date table marked as a date table in Power BI.Relationships between your sales table and the date table should be established correctly.

 

Hope this works . try both solutions . Thank you.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





lbendlin
Super User
Super User

 

looking for weekly sales comparion between current & last month

 

weeks and months are incompatible.

 

Best you can do is date math like so

 

Last Week Sales (PM) = CALCULATE([MTD Sales],DATEADD('Calendar'[Date],-7,DAY))
 
(whatever MTD means to you - you should use the Calendar Date for this.)

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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