cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

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

Accepted Solutions

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
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors