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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Shenee
Helper I
Helper I

Measure to show total of last day of previous week

I was wondering if anyone knew of a measure that I could use to calculate the total on the last day of the previous week and the week before (last day of the week ideally should be a saturday).

 

total for last day of  previous 2 weekstotal for last day of previous 2 weeks

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi  @Shenee ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create two measures as below:

Previous 1 week = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table'),
            'Table'[Date] < _seldate
                && WEEKNUM ( 'Table'[Date], 1 )
                    = WEEKNUM ( _seldate, 1 ) - 1
                && WEEKDAY ( 'Table'[Date], 2 ) = 6
        )
    )
Previous 2 week = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Date] < _seldate
                && WEEKNUM ( 'Table'[Date], 1 )
                    = WEEKNUM ( _seldate, 1 ) - 2
                && WEEKDAY ( 'Table'[Date], 2 ) = 6
        )
    )

yingyinr_0-1657266901276.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
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
v-yiruan-msft
Community Support
Community Support

Hi  @Shenee ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create two measures as below:

Previous 1 week = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table'),
            'Table'[Date] < _seldate
                && WEEKNUM ( 'Table'[Date], 1 )
                    = WEEKNUM ( _seldate, 1 ) - 1
                && WEEKDAY ( 'Table'[Date], 2 ) = 6
        )
    )
Previous 2 week = 
VAR _seldate =
    SELECTEDVALUE ( 'Table'[Date] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Date] < _seldate
                && WEEKNUM ( 'Table'[Date], 1 )
                    = WEEKNUM ( _seldate, 1 ) - 2
                && WEEKDAY ( 'Table'[Date], 2 ) = 6
        )
    )

yingyinr_0-1657266901276.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

@Shenee ,  Try measure like

 

Last Week Last day =
var _min = today() -WEEKDAY(today() ,2) -6 //Monday week start
var _max = _min +6
return CALCULATE([Net], FILTER('Date','Date'[Date] = _max))

 

last 2 last week

 

2nd Last Week Last day =
var _min = today() -WEEKDAY(today() ,2) -6 //Monday week start
var _max = _min +6 -7
return CALCULATE([Net], FILTER('Date','Date'[Date] = _max))

 

both together

 

Last day for last 2 weeks =
var _min = today() -WEEKDAY(today() ,2) -6 //Monday week start

var _max = _min +6
var _max1 = _min +6 -7
return CALCULATE([Net], FILTER('Date','Date'[Date] = _max || 'Date'[Date] = _max1))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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