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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power BI

Hi,

 

I want to do weekly analysis on this dataset and I am having trouble doing it. As shown in attached picture 01 "Last Week Sales" it shows the total sum of sales for that period of time. Whereas picture 02 shows how sales are divided for specific products. I want to see the same division of sales in picture 01 as for "Last Week Sales". How I can do it? 

 

I have created a measure for Last Week Sales, below is the code:

 
Last Week Previous Year Sales =
CALCULATE([Sales],
FILTER(ALL('sales'),
'sales'[startDateTime].[Year] = SELECTEDVALUE('sales'[startDateTime].[Year])-1&&
'sales'[Week] = SELECTEDVALUE('sales'[Week])))
 
Where, [Sales] is a measure SUM('sales'[subtotal])
& 'sales' is table name.
 
 

Your help will be really appreciated.

 

Thank you in advance

 

 

 

 

 

01

01.png

 

 

 

02

02.png

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Try this measure

Last Week Previous Year Sales =
VAR products = VALUES ( 'sales'[masterMapping] )
RETURN
    CALCULATE (
        [Sales],
        FILTER (
            ALL ( 'sales' ),
            'sales'[startDateTime].[Year] = SELECTEDVALUE ( 'sales'[startDateTime].[Year] ) - 1
                && 'sales'[Week] = SELECTEDVALUE ( 'sales'[Week] )
                && 'sales'[masterMapping] IN products
        )
    )

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Try this measure

Last Week Previous Year Sales =
VAR products = VALUES ( 'sales'[masterMapping] )
RETURN
    CALCULATE (
        [Sales],
        FILTER (
            ALL ( 'sales' ),
            'sales'[startDateTime].[Year] = SELECTEDVALUE ( 'sales'[startDateTime].[Year] ) - 1
                && 'sales'[Week] = SELECTEDVALUE ( 'sales'[Week] )
                && 'sales'[masterMapping] IN products
        )
    )

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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