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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.