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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Ishallown
Frequent Visitor

Need help with averagex , as its not showing the right amount in my visual

hi everyone,

 

i have an issue with my power BI visual , in the table below as you can see its showing 0.16552 , yet in the graph for the month of August its showing 0.21741 , both of them are from the same measure yet they are showing different results

 

Annotation 2020-09-01 192342.png

*Do note the one covered in black is just a customer number*

 

 my code as below for the ECL USD SMA:

 
ECL USD SMA =
AVERAGEX(
FILTER(vw_1_ECL,
[Report Run Date]<=MAX([Report Run Date])),
vw_1_ECL[ECL USD])
4 REPLIES 4
amitchandak
Super User
Super User

@Ishallown , the formula seems fine. but why your cumulative average is always increasing. Are using date table for display of month year. try formula like these with a date table

 

ECL USD SMA =
AVERAGEX(
FILTER(Date,
Date[Date]<=MAX([Report Run Date])),
vw_1_ECL[ECL USD])
 
or
ECL USD SMA =
AVERAGEX(
FILTER(Date,
Date[Date]<=MAX(Date[Date])),
vw_1_ECL[ECL USD])
 
 
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

hi! 
below is the sample data
i would like to show by country (legend) the moving averages (value ) and the shared axis being the report run date.

Payer NumberCountryCodeReport Run DateTotalExposureUSD
1SK0131-08-200.022227
1SK0128-08-200.022227
1SK0126-08-200.022227
1SK0125-08-200.022227
1SK0121-08-200.022227
1SK0119-08-200.022227
1SK0117-08-200.022227
1SK0114-08-200.022227
1SK0112-08-200.022227
1SK0110-08-200.022227
1SK0107-08-200.022227
1SK0105-08-200.022227
1SK0103-08-200.022227
1SK0131-07-200.01667
1SK0129-07-200.01667
1SK0127-07-200.01667
1SK0122-07-200.01667
1SK0120-07-200.01667
1SK0117-07-200.01667
1SK0115-07-200.01667
1SK0113-07-200.01667
1SK0110-07-200.01667
1SK0108-07-200.01667
1SK0106-07-200.01667
1SK0103-07-200.01667
1SK0101-07-200.01667
1SK0129-06-200.011113
1SK0124-06-200.011113
1SK0122-06-200.011113
1SK0119-06-200.011113
1SK0117-06-200.011113
1SK0115-06-200.011113
1SK0112-06-200.011113
1SK0110-06-200.011113
1SK0108-06-200.011113
1SK0101-06-200.011113
1SK0129-05-200.005557
1SK0122-05-200.005557
1SK0115-05-200.005557
1SK0108-05-200.005557
1SK0130-04-200
1SK0124-04-200
1SK0116-04-200
1SK0107-04-200
2SK0103-07-200.270229
2SK0106-07-200.270229
2SK0108-07-200.270229
2SK0110-07-200.32537
2SK0113-07-200.32537
2SK0122-07-200.370226
2SK0115-07-200.32537
2SK0127-07-200.370226
2SK0117-07-200.370226
2SK0129-07-200.370226
2SK0107-04-200
2SK0116-04-200
2SK0124-04-200
2SK0130-04-200
2SK0108-05-200.005557
2SK0115-05-200.005557
2SK0122-05-200.057414
2SK0129-05-200.057414
2SK0101-06-200.06297
2SK0108-06-200.11458
2SK0110-06-200.11458
2SK0112-06-200.11458
2SK0115-06-200.163029
2SK0119-08-200.412584
2SK0117-06-200.163029
2SK0119-06-200.213209
2SK0122-06-200.213209
2SK0124-06-200.213209
2SK0129-06-200.264672
2SK0101-07-200.270229
2SK0120-07-200.370226
2SK0131-07-200.370226
2SK0103-08-200.412584
2SK0105-08-200.412584
2SK0107-08-200.412584
2SK0110-08-200.412584
2SK0112-08-200.412584
2SK0114-08-200.412584
2SK0117-08-200.412584
2SK0121-08-200.412584
2SK0125-08-200.412584
2SK0126-08-200.412584
2SK0128-08-200.412584
2SK0131-08-200.412584
4IN0201-06-200.1234
4IN0202-06-200.564
4IN0203-06-200.225
4IN0207-07-200.1553
4IN0208-07-200.169
4IN0209-07-200.122
4IN0201-08-200.1365
4IN0202-08-200.188
4IN0203-08-200.889
4IN0204-08-200.954
4IN0205-08-200.44

thanks for the help

AntrikshSharma
Community Champion
Community Champion

Because at the Grand Total of the matrix you have all the dates visible for the AVERAGEX where as in the chart you are only filtering by one month, there is a difference in both.

Also you are not removing filters from vw_1_ECL using ALL ( vw_1_ECL ) so at each row of the report only one month will be visible and that will be the month returned by MAX too, you can verify this by removing "=" before MAX.

You should use Dates, Month & Year from the dates table and not from a fact table.

Hi Sharma ,

 

thanks for the reply , i was wondering then how would i able to calculate a simple moving average and also show the averages in the visual over a period of Months?  
im quite new to power BI thats why im not really familiar with what you said 😕

Helpful resources

Announcements
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.