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
tabish
Regular Visitor

calculates Day wise sales total filtered by calendar table

Trying to get the sum of sales weekday-wise (mon, tue, wed,..) for the same period in both years (the cumulative sum till last completed week of  2020 vs the same period in 2019), using below measure & it gives cumulative sum (both year) correctly but needs to have the sum for each year separately.
SalesYTD till last week = VAR Maxweek = CALCULATE(MAX('Calendar'[Day of Year]), ALL('Calendar'), 'Calendar'[CurWeekOffset] = -1)
RETURN CALCULATE([Total sales], 'Calendar'[Day of Year] <= Maxweek)
 
if I modify & puts a filter on for a year, it shows all values blank; 
SalesYTD 2020 till last week = VAR Maxweek = CALCULATE(MAX('Calendar'[Day of Year]), ALL('Calendar'), 'Calendar'[CurWeekOffset] = -1)
RETURN CALCULATE([Total sales], 'Calendar'[Day of Year] <= Maxweek,
FILTER(ALL('Calendar'),'Calendar'[Year] = MAX('Calendar'[Year])))
 
if I put months on rows it works correctly.

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@tabish 

Try add a year filter in your measure:

SalesYTD till last week = 

VAR Maxweek = CALCULATE(MAX('Calendar'[Day of Year]), ALL('Calendar'), 'Calendar'[CurWeekOffset] = -1)

RETURN CALCULATE([Total sales], 'Calendar'[Day of Year] <= Maxweek,'Calendar'[Date].[Year]=MAX([Date].[Year]))

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@tabish 

Try add a year filter in your measure:

SalesYTD till last week = 

VAR Maxweek = CALCULATE(MAX('Calendar'[Day of Year]), ALL('Calendar'), 'Calendar'[CurWeekOffset] = -1)

RETURN CALCULATE([Total sales], 'Calendar'[Day of Year] <= Maxweek,'Calendar'[Date].[Year]=MAX([Date].[Year]))

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

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.