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
Anonymous
Not applicable

Need help - Dynamic Average Calculated Measure

Hi all,

 

I have data in PowerBI as shown below in column A,B and C.

I want to create a calculated measure which gives the average value by objective and by month.

For example, if I filter month Feb19 and Mar19 then the [Avg by objective] should show number '2.5' and '5.5' for objective A and B, respectively (As shown in the second table).

Currently, my [Avg by objective] always shows the same value (the average of value by objective) and did not change when I filter the month.

 

Avg by objective = CALCULATE(AVERAGE('Table'[Value]), ALLEXCEPT(Table, 'Table[Objective]))
 
How could I achieve this? Any help would be appreciated. Thank you.

 

Example2.PNG

1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Please refer to the following DAX query:

Avg by objective =
VAR selectedvalues =
    ALLSELECTED ( 'Table'[Month] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Objective] = MIN ( 'Table'[Objective] )
                && 'Table'[Month] IN selectedvalues
        )
    )

The result will like below:

YJSsnHbF8o.gif

Best Regards,

Teige

View solution in original post

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Please refer to the following DAX query:

Avg by objective =
VAR selectedvalues =
    ALLSELECTED ( 'Table'[Month] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Objective] = MIN ( 'Table'[Objective] )
                && 'Table'[Month] IN selectedvalues
        )
    )

The result will like below:

YJSsnHbF8o.gif

Best Regards,

Teige

Anonymous
Not applicable

@TeigeGao Many thanks !!

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.