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! Learn more

Reply
Anonymous
Not applicable

Missing values per week - return latest active value

Guys im running into a problem at work here and through hours of googling and video-watching I have yet to find the answer.

 

Simply put:

 

I have weeks with a certain price for an item.

This is only showing in the data set if there is a price change.

If there is no price change then it doesnt show in the data.

 

Example:

Week 1 - 1,83 EUR

Week 3 - 1,85 EUR

Week 6 - 1,86 EUR

 

so week 2, 4, 5 are empty.

However I want to create a measure where it will show the latest price for that week.

 

Week 1 - 1,83 EUR

Week 2 - 1,83 EUR

Week 3 - 1,85 EUR

Week 4 - 1,85 EUR

Week 5 - 1,85 EUR

Week 6 - 1,86 EUR

 

The prices are also on date level but I want to set a price per week rather than day.

 

Any help is much appreciated here!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

If you have a large number of weeks, you may need to use dax to build a separate week table.

And  

 

WeekNum = SUBSTITUTE('Price'[Week],"Week ","")

 

Change the column type from text to whole number.

Then build Allweek Table.

 

AllWeek = ADDCOLUMNS(GENERATESERIES(MIN('Price'[WeekNum]),MAX('Price'[WeekNum]),1),"Week","Week"&" "&[Value])

 

Measurez:

 

Price = 
VAR _P1 =
    CALCULATE (
        MAX ( 'Price'[Price] ),
        FILTER ( 'Price', 'Price'[Week] = MAX ( AllWeek[Week] ) )
    )
VAR _MaxNum =
    MAXX (
        FILTER ( ALL ( 'Price' ), 'Price'[WeekNum] <= MAX ( AllWeek[Value] ) ),
        'Price'[WeekNum]
    )
VAR _P2 =
    CALCULATE (
        MAX ( 'Price'[Price] ),
        FILTER ( 'Price', 'Price'[WeekNum] = _MaxNum )
    )
RETURN
    IF ( _P1 = BLANK (), _P2, _P1 )

 

Result:

1.png

You can download the pbix file from this link: Missing values per week - return latest active value

 

Best Regards,

Rico Zhou

 

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
Anonymous
Not applicable

Hi @Anonymous 

If you have a large number of weeks, you may need to use dax to build a separate week table.

And  

 

WeekNum = SUBSTITUTE('Price'[Week],"Week ","")

 

Change the column type from text to whole number.

Then build Allweek Table.

 

AllWeek = ADDCOLUMNS(GENERATESERIES(MIN('Price'[WeekNum]),MAX('Price'[WeekNum]),1),"Week","Week"&" "&[Value])

 

Measurez:

 

Price = 
VAR _P1 =
    CALCULATE (
        MAX ( 'Price'[Price] ),
        FILTER ( 'Price', 'Price'[Week] = MAX ( AllWeek[Week] ) )
    )
VAR _MaxNum =
    MAXX (
        FILTER ( ALL ( 'Price' ), 'Price'[WeekNum] <= MAX ( AllWeek[Value] ) ),
        'Price'[WeekNum]
    )
VAR _P2 =
    CALCULATE (
        MAX ( 'Price'[Price] ),
        FILTER ( 'Price', 'Price'[WeekNum] = _MaxNum )
    )
RETURN
    IF ( _P1 = BLANK (), _P2, _P1 )

 

Result:

1.png

You can download the pbix file from this link: Missing values per week - return latest active value

 

Best Regards,

Rico Zhou

 

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

 

Anonymous
Not applicable

Hi @Anonymous,

 

thanks for the help. I have been able to rebuild your example.

Now There is an additional level of complexity in this.

 

The data is also on item and customer level.

How do I work this into your example?

 

Example data:

 

Week - item - customer - price

Week 1 - item a - cust 1 - 1,83

Week 1 - item a - cust 2 - 1,85

Week 2 - item b - cust 1 - 2,50

Week 2 - item a - cust 2 - 1,86

Week 3 - item a - cust 1 - 1,85

Week 5 - item b - cust 1 - 2,60

Week 6 - item a - cust 1 - 1,86

etc.

 

From this I want to be able to look at the price per customer and calculate (using the cost price per customer) the margin of each item per week.

 

I created a file with an example in.

example file 

amitchandak
Super User
Super User

@Anonymous , Create a separate week tabe with all weeks and try a formula like

 

calculate(lastnonblankvalue(Week[Week], max(Table[Value])), filter(allselected(Week), Week[Week] <=Max(Week[week])))

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

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