cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User IV
Super User IV

@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])))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

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.

 

 

View solution in original post

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors