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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BYENER
Helper V
Helper V

Return column X values of prev week if prev week column Z is empty

Hi All,

 

I need your help. If the prev week is empty (column A, B) than I want to return the last week values in column E, F, G, H.

Example: The prev week of week 6 is empty so I want to copy the values of week 5 (column E,F,G,H) to the column E,F,G,H of week 6. Is this possible? To summarize copy the values of E,F,G,H to all weeks that come after the week with values + 7 days.

 

I hope that my explanation is a little bit clear for  you.

 

BYENER_1-1611844100774.png

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi  @BYENER ,

 

According to my understanding, you want to get the value of E in previous week when the sum value on A is blank this week ,right?

You could use the following formula to create a new column:

Year-Week =
FORMAT ( [Date], "YYYY-WW" )
Column =
VAR _sum =
    CALCULATE ( SUM ( 'Table'[A] ), ALLEXCEPT ( 'Table', 'Table'[Year-Week] ) )
RETURN
    IF (
        _sum = BLANK (),
        CALCULATE (
            SUM ( 'Table'[E] ),
            FILTER ( 'Table', 'Table'[Date] = EARLIER ( 'Table'[Date] ) - 7 )
        ),
        [A]
    )

The final output is shown below:

2.2.5.1.gif

Please take a look at the pbix file here.

 

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

Hi @Anonymous , 
Thank you for your reply and example pbix file, but when I do the same in my report than I get the next error. It don't takes the date column while this table and column is exist, very strange.

 

BYENER_1-1612294405017.png

 

Anonymous
Not applicable

Hi @BYENER ,

 

I used EARLIER() function in calculated column not measure.

 

Best Regards,
Eyelyn Qin

amitchandak
Super User
Super User

@BYENER , These value are not of same type.

You need a week before or Week on week

example

This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
7 behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-7,DAy))

 

Measure = if(isblank([This Day]), [7 behind Sales] ,[This Day])

 

Or do same with this week and last week 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors