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
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
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.