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
Charu
Post Patron
Post Patron

How to use both Avg and sum function in DAX

Hi Everyone,

 

I have 4columns like below

Col1 : Col2 : Col3 : Col4

0         0       1         0

I want to first sum these 4 columns and then need to get Average.

Please help me how to create DAX formula

 

In KPI Visual I need to use that Avg measure in the Target Label

6 REPLIES 6
jcarville
Skilled Sharer
Skilled Sharer

You can unpivot the 4 columns to create 1 column. Then use this new column and change the type to sum or average using the drop down arrow under the values section of the visualisations pane.

PietroFarias
Resolver II
Resolver II

Do you want sum Col1 + Col2 + Col3 + Col4 and make a average this sum?

 

If so, then:

Measure:= AVERAGEX(Tab1;[Col1]+[Col2]+[Col3]+[Col4])

HI @PietroFarias

I tried the measure but I'm getting following error

Error Message:
ORA-00904: "t1"."QTR2_TARGET": invalid identifier. The exception was raised by the IDbCommand interface.

Anonymous
Not applicable

@Charu,

Do you connect to Oracle in Power BI Desktop? Could you please post a screenshot about how you apply PietroFarias's DAX in your table?

Regards,
Lydia

Hi @Anonymous

 

Yeah, I'm connecting oracle database direct query mode and in the advanced options passing SQL statements(many tables join) and getting data.

Sample is 

ID | Code | Tgt 1 | Tgt2 | Tgt3 | Tgt4

1  | 001    | 0       |  0     | 0      | 0

2  | 003    | 1       |  0     | 0      | 0

 

I need to take sum (tgt1,tgt2,tgt3,tgt4) and then the Avg of the sum(tgt1,tgt2,tgt3,tgt4)

I have created measure as suggest by @PietroFarias

Measure:= AVERAGEX(Tablename;[Tgt1]+[Tgt2]+[Tgt3]+[Tgt4])

Oh! This case, AVERAGEX not is Supported. In measure and query formulas only.

DAX formula compatibility in DirectQuery mode

 

 

See the post below, from this forum, if you help.

Forum: Average of Measure in Direct Query mode

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.