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
minhvuong93
Helper II
Helper II

Data selection for latest 'available' month

Hello everyone,

I have a dataset of 12 months in 2017.

 

Customer ID _ Sales volume _ Month

A1                  _    100            _  Jan

A2                  -   50               _ Jan

A3                   -  120              _ Jan

-.....

A1               _ 120 __             Dec

A2                _30 _                 Dec

 

I would like to filter list of customer remaining in December. (as some customers quit during the year)

Then calculate the average volume sales of the whole year (not only Dec)

How can I accomplish this?

 

Thanks so much if you can help me, 🙂

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Easiest thing to do would be to create a measure like:

 

AverageLatest = CALCULATE(AVERAGE(CustomersLatest[Sales]),ALLEXCEPT(CustomersLatest,CustomersLatest[CustomerID]))

Then create a table visualization with CustomerID. Drage Month to your visual filter area and filter to "Dec". Then, drag in your AverageLatest measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

Easiest thing to do would be to create a measure like:

 

AverageLatest = CALCULATE(AVERAGE(CustomersLatest[Sales]),ALLEXCEPT(CustomersLatest,CustomersLatest[CustomerID]))

Then create a table visualization with CustomerID. Drage Month to your visual filter area and filter to "Dec". Then, drag in your AverageLatest measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler

Also , could you help me to explain,

what if the customers have the 1st sales in , lets say, OCT and DEC , but no sales in NOV.

So for AVERAGE in this case, will it be: total sales divided by 2 or by 3 month?

The AVERAGE function is going to take care of all of that and when you put it in a table for each customer, it will be per customer. So, if one customer has 5 entries and another 2 and another 12, AVERAGE will calculate the average correctly, no worries.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler

Thanks for helping quickly,

 

Can I add a filter into this measure to ensure the volume >0

since some of the order quantity might be < 0 (back orders, return goods...)

 

Average_volume= CALCULATE(AVERAGE(customers[OrderQuantity]),customers[OrderQuantity]>0,ALLEXCEPT(MK,MK[customersID]))

Yes, that should work.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thanks for your quick reply,

What is the "CustomerLatest" from?

Does that mean i have to create a new table with only Dec?

No, that's just the name I gave my table when I recreated your data.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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
Top Kudoed Authors