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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
dollarvora
Helper I
Helper I

Calculate YTD average sales by customer number based on current year and week

I've a data set as under:

IDFISCAL_YEARFISCAL_WEEK
1202053
120211
120215
2201952
320209
2201828
3202053
420211
520215
2201952
5202053
220211

I want to create a measure to plot on a clustered column with one bar pair showing Sales(Counts) by a selected ID (this ID would be picked using a slicer) for this year (until current week number) vs the average number of sales by ID for this year (until current week number) 

And the second pair of bars would represent the same information but for last year(until the same week number as today)

 

1 ACCEPTED SOLUTION

Hi @dollarvora ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1601969406770.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@dollarvora , First of all create a column  Year Week. Given Below.

Year Week = [Year]*100 +[Week]

 

Create a Date /Week Table

Date = Summarize(Table, [Year], [Week],[Year week])

 

Join both on Year Week. These are a formula for Year till week


YTD= CALCULATE(Avergae('Table'[ID]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] <= Max('Date'[Week]) ))
LYTD = CALCULATE(Avergae('Table'[ID]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] <= Max('Date'[Week])))

Hi @amitchandak ,

dollarvora_0-1600922735471.png

 


This is really helpful, thanks

But, as I mentioned in the original question I have a slicer that selects the ID, I'd want 2 pairs of bar charts side by side

1st one: Comparing the YTD sales for that selected ID v/s YTD vs the average number of sales by ID for this year
2nd one: same but for the lasy YTD

Thanks again

Hi @dollarvora ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1601969406770.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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