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
bkirshenbaum
Frequent Visitor

Last Week Data for a Measure

Hello!

 

I am trying to display the current week's Leasing % as well as the Previous Week's in the same table.

 

I created the following measure that captures the current week's Preleasing: 

 
Calc Preleased % = CALCULATE(SUM('Property Info'[calcPreleased]),FILTER('Property Info','Property Info'[Modified]=MAX('Property Info'[Modified])))
 
However, I have had no success capturing the previous week's data. 
 
Sample data is below.
 
Thank you!
 
Property IDIdModifiedCreatedcalcOccupiedcalcPreleasedID.1
1237/8/2019 1:50:19 PM7/8/2019 1:50:19 PM99.05%100.00%58840
2247/6/2019 12:14:09 AM7/6/2019 12:14:09 AM100.00%0.00%58824
1247/3/2019 6:47:30 PM7/3/2019 6:47:30 PM98.50%99.00%58769
2247/19/2019 7:01:17 PM7/19/2019 7:01:17 PM100.00%0.00%60075
2247/19/2019 7:01:09 PM7/19/2019 7:01:09 PM100.00%0.00%60074
1237/19/2019 1:46:50 PM7/19/2019 1:46:50 PM99.05%100.00%59841
1247/19/2019 1:41:10 PM7/19/2019 1:41:10 PM97.13%99.70%59836
1237/19/2019 1:40:02 PM7/19/2019 1:40:02 PM99.05%100.00%59835
2247/12/2019 8:18:23 PM7/12/2019 8:18:23 PM100.00%0.00%59565
1247/12/2019 3:41:12 PM7/12/2019 3:41:12 PM98.50%99.00%59363
1237/12/2019 2:14:03 PM7/12/2019 2:14:03 PM99.05%100.00%59314
1237/12/2019 2:13:49 PM7/12/2019 2:13:49 PM99.05%100.00%59313
2246/8/2019 12:47:13 AM6/8/2019 12:47:13 AM100.00%0.00%56870
1246/7/2019 3:25:44 PM6/7/2019 3:25:44 PM98.50%97.30%56560
1236/7/2019 1:46:33 PM6/7/2019 1:46:33 PM99.05%100.00%56514
1236/7/2019 1:43:57 PM6/7/2019 1:43:57 PM99.05%100.00%56513
2246/28/2019 7:26:26 PM6/28/2019 7:26:26 PM100.00%0.00%58461
1246/28/2019 4:28:13 PM6/28/2019 4:28:13 PM98.50%98.50%58340
1236/28/2019 1:26:43 PM6/28/2019 1:26:43 PM99.05%100.00%58221
2246/21/2019 9:56:32 PM6/21/2019 9:56:32 PM100.00%0.00%57974
1236/21/2019 1:42:28 PM6/21/2019 1:42:28 PM99.05%100.00%57640
1246/20/2019 4:39:15 PM6/20/2019 4:39:15 PM98.50%98.50%57595
1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi bkirshenbaum,

You could use below measures to get current week and previous week’s value

previous week =
CALCULATE (
    SUM ( 'Property Info'[calcPreleased] ),
    FILTER (
        ALL ( 'Property Info' ),
        'Property Info'[Property IDId] = MIN ( 'Property Info'[Property IDId] )
            && 'Property Info'[Created]
                > TODAY () - 14
            && 'Property Info'[Created]
                <= TODAY () - 7
    )
)
this week =
CALCULATE (
    SUM ( 'Property Info'[calcPreleased] ),
    FILTER (
        ALL ( 'Property Info' ),
        'Property Info'[Property IDId] = MIN ( 'Property Info'[Property IDId] )
            && 'Property Info'[Created]
                > TODAY () - 7
            && 'Property Info'[Created] <= TODAY ()
    )
)

126.png

Best Regards,

Zoe Zhi

 

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

3 REPLIES 3
dax
Community Support
Community Support

Hi bkirshenbaum,

You could use below measures to get current week and previous week’s value

previous week =
CALCULATE (
    SUM ( 'Property Info'[calcPreleased] ),
    FILTER (
        ALL ( 'Property Info' ),
        'Property Info'[Property IDId] = MIN ( 'Property Info'[Property IDId] )
            && 'Property Info'[Created]
                > TODAY () - 14
            && 'Property Info'[Created]
                <= TODAY () - 7
    )
)
this week =
CALCULATE (
    SUM ( 'Property Info'[calcPreleased] ),
    FILTER (
        ALL ( 'Property Info' ),
        'Property Info'[Property IDId] = MIN ( 'Property Info'[Property IDId] )
            && 'Property Info'[Created]
                > TODAY () - 7
            && 'Property Info'[Created] <= TODAY ()
    )
)

126.png

Best Regards,

Zoe Zhi

 

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

@dax This works great with one exception.

 

Sometimes we have data that gets entered twice in a week to correct an error. How can I make these not aggregate the totals and instead just show the more recent of the two?

 

Thank you!

Anonymous
Not applicable

Hi @bkirshenbaum 

Please check the following post, depends on the date table created this measure can be created in different ways.

https://community.powerbi.com/t5/Desktop/Measure-displaying-last-week-sum/td-p/495437

https://community.powerbi.com/t5/Desktop/Previous-Week-and-Previous-Month-DAX/td-p/550431

 

Thanks

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.