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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Super User
Super User

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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