Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dejw
New Member

Equivalent of averageIFS in powerBI (powerPiwot)

Hello community, I would like to know if its possible to calculate value using DAX in generated table in powerPiwot (in my case). The calculations I would like to make are equivalent of using AVERAGEIFS in excel. I need to get one average number for goods with same condition. I have sample of goods sold (in my currency) during several months from several stocks. I need to calculate column with AVERAGE NUMBER of sells during my time period with STOCK and GoodsID as an condition of calculation. It means that result in new column should be same number(average) for each GoodsID on specific stock during several months that are included in the source table.

Dejw_0-1658465472507.png

 

If I am doing it in excel I would do it this way (unfortunatelly not possible using DAX)

Dejw_1-1658466141477.png

This is exactly what I need > CRITERIA of averageifs function is item in each row and calculations are made for each row (each GoodsID on specific Stock) across whole time period.

 

Thanks a lot for your advice! 

 

D.

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Dejw 

 

I restored your data, please try the following method.

vzhangti_0-1658826935219.png

Column:

Average =
CALCULATE (
    AVERAGE ( 'Table'[Sold] ),
    FILTER (
        'Table',
        [STOCK] = EARLIER ( 'Table'[STOCK] )
            && [GoodsID] = EARLIER ( 'Table'[GoodsID] )
    )
)

vzhangti_1-1658826985412.png

Is this the output you expect in Desktop?

 

Best Regards,

Community Support Team _Charlotte

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

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @Dejw 

 

I restored your data, please try the following method.

vzhangti_0-1658826935219.png

Column:

Average =
CALCULATE (
    AVERAGE ( 'Table'[Sold] ),
    FILTER (
        'Table',
        [STOCK] = EARLIER ( 'Table'[STOCK] )
            && [GoodsID] = EARLIER ( 'Table'[GoodsID] )
    )
)

vzhangti_1-1658826985412.png

Is this the output you expect in Desktop?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-zhangti ! That is exactly what I needed, thakns a lot, just for my info for expample difference between [STOCK] and ( 'Table'[STOCK]) is that first one refers to to item on specific row whereas second one refers to the whole column in specific table? Thanks a lot man !

yes, it's the difference between a row context and a filter context.  Note that you _could_  add the table name to a row context reference, and it would still work.  But you cannot have a filter context without the table name.

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. I cannot help you without usable sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. I cannot use screenshots of your source data.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Hi ! thanks a lot for your response, Attached see data, column AVERAGEIFS is what I need to calculate in PowerPivot for every GoodsID. Formula should calculate Average number of sales of specific GoodsID, on specific stock during the set time period.

 

MonthSTOCKGoodsIDSoldAVERAGEIFS    
VI.22HS030PV1FATHE03216 544,806 544,80 >>>EXPECTED OUTCOME
VI.22HS030PV1FATHE03436 544,80     
VI.22HS030PV1TAIDC000937 276,37     
I.21HS020DOPFASCH0022288,00     
I.21HS020CH3HEK1800182 578,26     
II.21HS020PV1FATHE032111 793,605 933,56 >>>EXPECTED OUTCOME
II.21HS020VINFAVEP002939 463,22     
II.21HS020CH3HEK1800181 289,13     
V.21HS020PV1FATHE032173,525 933,56 >>>EXPECTED OUTCOME
II.21HS020DOPGHUKP00025,05     
II.21HS020DOPGHUKP003020,54     
II.21HS020DOPGHUKP00445,14     
II.21HS020NARCONAV0004117,50     

 

AverageIFS formula used in excel: "=AVERAGEIFS($D$2:$D$14;$C$2:$C$14;C2;$B$2:$B$14;B2)" ; where "MONTH" is in cell A1

 

Hopefully this helps you, let me know, thank you a lot D.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.