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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
SeanB004
Frequent Visitor

Duplicate values for Previous Week measure

Hi All, 
I have a measure calculating Current Week and Previous week sales, grouped by the Status. However when it shows the previous week value, it duplicates the value and doesnt show it's statuses respective amount. as illustated below, the 19 for Previous week should be broken down into 12 and 7 for each status respectively. how do I fix this formula

SeanB004_0-1697668242678.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SeanB004 ,

 

Please try code as below.

 

PreviousWeekOppts =
VAR _SUMMARIZE =
    SUMMARIZE (
        'Oppts (2)',
        'Oppts (2)'[Week Ending Date],
        'Oppts (2)'[Status],
        "PreviousWeekOppts",
            CALCULATE (
                [Number of Oppts],
                FILTER (
                    ALL ( 'Oppts (2)' ),
                    'Oppts (2)'[Status] = MAX ( 'Oppts (2)'[Status] )
                        && 'Oppts (2)'[Week Ending Date]
                            = MAX ( 'Oppts (2)'[Week Ending Date] ) - 7
                )
            )
    )
RETURN
    SUMX ( _SUMMARIZE, [PreviousWeekOppts] )

 

Result is as below.

vrzhoumsft_0-1698301596110.png

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @SeanB004 ,

 

Please try code as below.

 

PreviousWeekOppts =
VAR _SUMMARIZE =
    SUMMARIZE (
        'Oppts (2)',
        'Oppts (2)'[Week Ending Date],
        'Oppts (2)'[Status],
        "PreviousWeekOppts",
            CALCULATE (
                [Number of Oppts],
                FILTER (
                    ALL ( 'Oppts (2)' ),
                    'Oppts (2)'[Status] = MAX ( 'Oppts (2)'[Status] )
                        && 'Oppts (2)'[Week Ending Date]
                            = MAX ( 'Oppts (2)'[Week Ending Date] ) - 7
                )
            )
    )
RETURN
    SUMX ( _SUMMARIZE, [PreviousWeekOppts] )

 

Result is as below.

vrzhoumsft_0-1698301596110.png

 

Best Regards,
Rico Zhou

 

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

 

amitchandak
Super User
Super User

@SeanB004 , Try with a date table

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format


These measures can help
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors