Forum Discussion

SeanB004's avatar
SeanB004
Frequent Visitor
2 years ago
Solved

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 statuse...
  • Anonymous's avatar
    Anonymous
    2 years ago

    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.

     

    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.