cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tainguyen Frequent Visitor
Frequent Visitor

Showing Previous Month and Week Data

Hi Guys,

 

I need help on displaying data from previous month and week

 

As you can see from the attached file, I need to show previous week and month of meetings booked.

 

Thanks for helping in advance!

 

Screenshot

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yulgu-msft Super Contributor
Super Contributor

Re: Showing Previous Month and Week Data

Hi @tainguyen ,

 

You need a MonthNo column in ScoreCard table.

MonthNo =
SWITCH (
    TRUE (),
    ScoreCard[Month] = "January", 1,
    ScoreCard[Month] = "Febuary", 2,
    ScoreCard[Month] = "March", 3,
    ScoreCard[Month] = "April", 4,
    ScoreCard[Month] = "May", 5,
    ScoreCard[Month] = "June", 6,
    ScoreCard[Month] = "July", 7,
    ScoreCard[Month] = "August", 8,
    ScoreCard[Month] = "September", 9,
    ScoreCard[Month] = "October", 10,
    ScoreCard[Month] = "November", 11,
    ScoreCard[Month] = "December", 12
)

Also, create a calculated table which lists unique Month names and Weeks. Make sure this table is unrelated to ScoreCard table.

Slicer table =
CROSSJOIN ( VALUES ( ScoreCard[Week] ), VALUES ( ScoreCard[Month] ) )

Then, add below measures together with 'ScoreCard'[Trainee] into visual.

Curr_Meetings =
CALCULATE (
    SUM ( ScoreCard[Meetings] ),
    FILTER (
        ALLEXCEPT ( ScoreCard, ScoreCard[Trainee] ),
        ScoreCard[Month] = SELECTEDVALUE ( 'Slicer table'[Month] )
            && ScoreCard[Week] = SELECTEDVALUE ( 'Slicer table'[Week] )
    )
)

prev_Meetings =
VAR curr_Monthno =
    CALCULATE (
        MAX ( ScoreCard[MonthNo] ),
        FILTER (
            ALLSELECTED ( ScoreCard ),
            ScoreCard[Month] = SELECTEDVALUE ( 'Slicer table'[Month] )
        )
    )
RETURN
    CALCULATE (
        SUM ( ScoreCard[Meetings] ),
        FILTER (
            ALLEXCEPT ( ScoreCard, ScoreCard[Trainee] ),
            ScoreCard[MonthNo] = curr_Monthno - 1
                && ScoreCard[Week] = SELECTEDVALUE ( 'Slicer table'[Week] )
        )
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft Super Contributor
Super Contributor

Re: Showing Previous Month and Week Data

Hi @tainguyen ,

 

You need a MonthNo column in ScoreCard table.

MonthNo =
SWITCH (
    TRUE (),
    ScoreCard[Month] = "January", 1,
    ScoreCard[Month] = "Febuary", 2,
    ScoreCard[Month] = "March", 3,
    ScoreCard[Month] = "April", 4,
    ScoreCard[Month] = "May", 5,
    ScoreCard[Month] = "June", 6,
    ScoreCard[Month] = "July", 7,
    ScoreCard[Month] = "August", 8,
    ScoreCard[Month] = "September", 9,
    ScoreCard[Month] = "October", 10,
    ScoreCard[Month] = "November", 11,
    ScoreCard[Month] = "December", 12
)

Also, create a calculated table which lists unique Month names and Weeks. Make sure this table is unrelated to ScoreCard table.

Slicer table =
CROSSJOIN ( VALUES ( ScoreCard[Week] ), VALUES ( ScoreCard[Month] ) )

Then, add below measures together with 'ScoreCard'[Trainee] into visual.

Curr_Meetings =
CALCULATE (
    SUM ( ScoreCard[Meetings] ),
    FILTER (
        ALLEXCEPT ( ScoreCard, ScoreCard[Trainee] ),
        ScoreCard[Month] = SELECTEDVALUE ( 'Slicer table'[Month] )
            && ScoreCard[Week] = SELECTEDVALUE ( 'Slicer table'[Week] )
    )
)

prev_Meetings =
VAR curr_Monthno =
    CALCULATE (
        MAX ( ScoreCard[MonthNo] ),
        FILTER (
            ALLSELECTED ( ScoreCard ),
            ScoreCard[Month] = SELECTEDVALUE ( 'Slicer table'[Month] )
        )
    )
RETURN
    CALCULATE (
        SUM ( ScoreCard[Meetings] ),
        FILTER (
            ALLEXCEPT ( ScoreCard, ScoreCard[Trainee] ),
            ScoreCard[MonthNo] = curr_Monthno - 1
                && ScoreCard[Week] = SELECTEDVALUE ( 'Slicer table'[Week] )
        )
    )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 53 members 1,047 guests
Please welcome our newest community members: