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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dpc_development
Helper III
Helper III

Calculate average of calculated measure across all dimensions

Please see this uploaded Power BI file. With help from @OwenAuger I have a calculated measure called 'cumulative_return'. I am then calculating another measure called '7d_cumulative_return', which is basically the cumulative_return as on seven days prior to the current last_updated date.

 

Now, I need to calculate the average of 7d_cumulative_return across all lists. You will notice that the values for list 2 & 1027 on the 3rd is 1.051 and 1.085, and on 4th is 0.906 and 0.923, respectively. Thus my new measure should return 1.068 and 0.9145, respectively.

 

This is the formula that I have for now.

 

avg_7d_cumulative_return = 
var onDate = MAX('CMC Daily Return'[last_updated])
RETURN 
CALCULATE(
    AVERAGEX(ALLSELECTED('CMC Daily Return'), [7d_cumulative_return]),
    'CMC Daily Return'[last_updated] <= onDate,
    ALLSELECTED('CMC Daily Return')
)

 

It starts well, but shows a wrong value from the second day onward. How can I get the average of a measure that depends on a dimension, but I need the average across all dimension values.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi there @dpc_development 

 

To calculate the average of the existing measure [7d_cumulative_return] over the list_id, you can use a measure like below.

This assumes you want to show the same average across all selected list_id values.

avg_7d_cumulative_return = 
AVERAGEX ( 
    ALLSELECTED ( 'CMC Daily Return'[list_id] ),
    [7d_cumulative_return]
)

Since all the logic around date filters is captured in the underlying measures, you don't need to rewrite any date filters in this measure.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi there @dpc_development 

 

To calculate the average of the existing measure [7d_cumulative_return] over the list_id, you can use a measure like below.

This assumes you want to show the same average across all selected list_id values.

avg_7d_cumulative_return = 
AVERAGEX ( 
    ALLSELECTED ( 'CMC Daily Return'[list_id] ),
    [7d_cumulative_return]
)

Since all the logic around date filters is captured in the underlying measures, you don't need to rewrite any date filters in this measure.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors