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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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