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
Anonymous
Not applicable

Remove last day production of each category

Hello everyone,
I want to make an average per day of the production of each Item then sum it, BUT I want to remove te last day of production per item.

I Want to remove the last day of the average because if i don´t do so i will make me average go under the real number.

 Here under I have a simple example of it (The red numbers are the numbers I want removed.


 

DateProduct 1 Product 2Product 3 
01/01/2018500010050 
02/01/2018500010050 
03/01/2018500010025 
04/01/20185000100  
05/01/20185000100  
06/01/20185000100  
07/01/20182500100  
08/01/2018 50  
09/01/2018   Average
Average5000100501716,667


The table in the database that I have presents 3 colums, Product / Date / Value

ProductDateValue
Product 1 01/01/2018XXX
Product 202/01/2018XXX
Product 303/01/2018XXX
Product 1 04/01/2018XXX
Product 205/01/2018XXX
Product 306/01/2018XXX
Product 1 07/01/2018XXX
Product 208/01/2018XXX
Product 309/01/2018XXX
Product 310/01/2018XXX


Thanks in regards



5 REPLIES 5
Anonymous
Not applicable

Hello everyone, thanks for the answer.

I tried to make the following DAX Formula:

AVERAGEX(
 KEEPFILTERS(VALUES('TABLE'[Date]);
 CALCULATE(MEASURE)

And it worked really fine, the problem is that doesnt filter the last day....


Did you try my technique to get rid of the last day in your calculation?


@ 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...
Anonymous
Not applicable

Greg!
I did your technique, and almost worked!
The problem is, is making a average of each line instead of the average per day.

In the example below, it should give me on day 01 the value of 50, and day 2 a number of 100.

I think is something with KEEPFILTERS, but I can´t get it right...

DateProductValue
01/01/2018Product 125
01/01/2018Product 125
01/02/2018Product 125
01/02/2018Product 125
01/02/2018Product 125
01/02/2018Product 125



Thanks!

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Assuming that you have the data sample like below.

 

data sample.PNG

 

Please filter rows like below in Query Editor and then apply and close.

 

filter rows.PNG

 

Then you could create a calculated column with the formula like this.

Column =
VAR a =
    CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Product] ) )
RETURN
    IF ( 'Table'[Date] = a, BLANK (), 'Table'[Value] )

Here is the output.

 

result.PNG

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

You should be able to do something like:

 

Measure = 
VAR __product = MAX([Product])
VAR __table = FILTER('Table',[Product]=__product)
VAR __max = MAXX(__table,[Date])
VAR __table1 = FILTER(__table,[Date]<>__max)
RETURN
AVERAGEX(__table1,[Value])

This assumes that the data in Power BI is in the 2nd example posted.


@ 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.