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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Bobass75
Regular Visitor

last sales / last sales in month

Hello
Seems simple but I need help. I need to show last day sales sum in a month as below (Last sales measure):

   Measures
YearmonthDatesalesLast sales
2023101.01.2023100 
2023102.01.2023200 
2023103.01.2023300 
2023104.01.2023400 
2023105.01.2023500 
2023106.01.2023600 
2023107.01.2023700 
2023108.01.2023800 
2023109.01.2023900 
2023110.01.20231000 
2023111.01.20231100 
2023112.01.20231200 
2023113.01.20231300 
2023114.01.20231400 
2023115.01.20231500 
2023116.01.20231600 
2023117.01.20231700 
2023118.01.20231800 
2023119.01.20231900 
2023120.01.20232000 
2023121.01.20232100 
2023122.01.20232200 
2023123.01.20232300 
2023124.01.20232400 
2023125.01.20232500 
2023126.01.20232600 
2023127.01.20232700 
2023128.01.20232800 
2023129.01.20232900 
2023130.01.20233000 
2023131.01.202331003100
2023201.02.20233200 
2023202.02.20233300 
2023203.02.20233400 
2023204.02.20233500 
2023205.02.20233600 
2023206.02.202337003700

the model includes standard sales fact and date,product etc tables. 

Thank you in advance
Leszek


3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like but please check the below picture and the attahchd pbix file.

 

Jihwan_Kim_0-1690740285272.png

 

 

Last sales in the month: =
VAR _lastdatenonblank =
    LASTNONBLANK ( 'Calendar'[Date], CALCULATE ( SUM ( Sales[Sales] ) ) )
RETURN
    CALCULATE ( SUM ( Sales[Sales] ), 'Calendar'[Date] = _lastdatenonblank )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


tamerj1
Super User
Super User

Hi @Bobass75 

Please try

Last Sales =
SUMX (
SUMMARIZE (
Sales,
'Date'[Year],
'Date'[Month],
"@LastSales",
VAR MaxDate =
CALCULATE ( MAX ( 'Date'[Date] ), ALL ( 'Date'[Date] ) )
RETURN
CALCULATE ( SUM ( sale[Sales] ), KEEPFILTERS ( 'Date'[Date] = MaxDate ) )
),
[@LastSales]
)

Thank you all - you've helped me a lot 🙂

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.

Top Solution Authors