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,
16 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 II
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.
- zlotttRegular Visitor
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.
- v-aatheeque
Community Support
Hi zlottt
Could you please share the sample PBIX file or provide a small sample of the data and the current measure?
This will help clarify whether you want the average of the yearly values shown in the matrix (2023, 2024, 2025, 2026) or the average of the underlying records. It will also help determine whether the calculation should be done using DAX or Power Query.
Need help uploading data?
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/144…- zlotttRegular Visitor