Forum Discussion
Calculating Average question
Hi everyone,
I am new to power bi and I am starting a report where the source file is a basic excel file. I have created a matrix and added the data I needed it, please see the attached.
My challenge is instead of having the TOTAL column I would need to have an average column, calculating the average from the years 2023 to 2026.
Is there a way to make the calculations on the back end (power query) or just on the front end creating a new measure?
Could you give me an assist please.
Thank you in advance,
6 Replies
- Ashish_Mathur
Super User
Hi,
Assuming the numbers in the matrix are the result of this measure
Value = sum(Data[Amount])
try this measure
Value revised = if(hasonevalue(Calendar[Year]),[Value],averagex(values(calendar[Year]),[Value]))
Hope this helps.
- danextian
Super User
You can straight use AVERAGEX to iterate through the value of each year before getting the average
Units Sold Yearly Avg =
AVERAGEX ( -- Calculate the average across the years
VALUES ( 'Date'[Year] ), -- Get each selected year
[Units Sold] -- Calculate Units Sold for each year
)
Note: AVERAGEX exclude blank rows. In the example below, although there are 16 years from 1999 to 2014, 1999 is blank so the average is 118500/15 = 7900
- ryan_mayu
Super User
could you pls provide some sample data (not the table visual) and the expected output based on the sample data?
- Praful_Potphode
Super User
Hi zlottt
Please try sample pbix.
Please give kudos or mark it as solution once confirmed,
Regards,
Praful
- DaniyalKhaleel1
Resolver I
Yes,Use a DAX measure rather than Power Query.
Average 2023-2026 =
AVERAGEX(
VALUES('Table'[Year]),
CALCULATE(SUM('Table'[Value]))
)
This will calculate the average dynamically based on the selected years/filters.
Recommendation Use Power Query for data transformation and DAX measures for calculations like averages, totals, percentages, etc.
- zlotttNew Member
Hi everyone,
Sorry for the late reply.
I dont have any measures on the table, the values on the matrix are just a count of number of work orders and I wanted to have an average of the amount of work orders.
Thank you very much everyone.