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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jagutierrezm
Frequent Visitor

Last sale of each product in the week

Hello good afternoon,

 

1. I have a sales table called "Prov Sales"

2. it has a Date, SKU, Quantity field

3. I have a Date table:

https://www.sqlbi.com/articles/reference-date-table-in-dax-and-power-bi/#

4. The week starts on Monday and we are consulting week 48 (Nov-23 to Nov-29)

5. I have to add the last sale of each product in the selected week.

5.1. Use LASTNONBLANKVALUE but bring only the last day and there are SKUs that were last sold before the last day of the week.

Prov Units = LASTNONBLANKVALUE ('Date' [Date], SUM ('Prov Sales' [Quantity]))

6. In the example the last sale of each product was:

SKU "100119" -> 2020-11-26 Quantity = 19

SKU "100118" -> 2020-11-29 Quantity = 1

SKU "122336" -> 2020-11-29 Quantity = 2

Total Quantity = 22

With the measure I have, it returns Quantity = 3

 

26.png

 

29.png

salesUnit.png

How can I make a Measurement that adds up the last sale of each product in the selected week?

With this measure, how could you apply it to a measure with the value of the previous week?

 

Health and Regards.

 

1 REPLY 1
AlB
Community Champion
Community Champion

Hi @jagutierrezm 

Can you

1.  show the code for your measure and explain where/how yo intend to use it (what fields/filters there are in the visual, etc.)

2.  show a sample of the relevant tables in your model. Or best if you can share the pbix

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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