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

Average based on criteria from another column

Hi,

 

I have some information in CSV and wants to do calculations based on criteria (an average of output if ID's are the same)

 

In Excel à Column A contains "output" column B and C are ID's and in column D is the Excel calculation.

 

=AVERAGEIF(C:C;B2;A:A)

 is the Excel formula in D2 

 

 Excel_vs_PowerBI.png

 

 

 

In Power Bi I've tried EARLIER and VLOOKUPS but I don't get the desired result. I think it isn't very difficult, but I cannot find it 😞

 

Thnx,

 

Manfred

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @Anonymous,

In your resource data, the ID1 and ID2 are same, so you can add any one to the filter. Please create a calculated column using the following formula and get expected result.

AVG = CALCULATE(AVERAGE(Table5[Output]),FILTER(Table5,Table5[ID1]=EARLIER(Table5[ID1])))

11.png

 

If you have any other issue, please feel free to ask.


Best Regards,
Angelia

View solution in original post

2 REPLIES 2
v-huizhn-msft
Employee
Employee

Hi @Anonymous,

In your resource data, the ID1 and ID2 are same, so you can add any one to the filter. Please create a calculated column using the following formula and get expected result.

AVG = CALCULATE(AVERAGE(Table5[Output]),FILTER(Table5,Table5[ID1]=EARLIER(Table5[ID1])))

11.png

 

If you have any other issue, please feel free to ask.


Best Regards,
Angelia

Anonymous
Not applicable

Hi Angelia,

 

Thnx for helping me. This works great and now I know what went wrong.

 

For the explanation I've created an example in Excel named the column Output. When I import the Excel file it goes fine. Normally I'll do first a SUMX to calculate different columns and then I want to do the earlierformule. SUMX only works with a measure

 

Your answer works perfect with my question so we close this post and I'll create a new explanation

 

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.