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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
User232431
Helper I
Helper I

Calculate Average / Sum of other rows based on slicer selection

Hi Need help on getting average of values for some other rows,

Ex: If user select value from name column with in those slicers then card should show average of other rows base on same slicers

 

Avg_1.png

 

If user select Name - "A" with nsome slicers the in card value should be average of value for the same slicers, In my below example showing average of all values (13) irrespective of slicers instead of 10.

avg_2.png

 

The measure that i wrote is as below:

_newmeasure =
VAR _dpv = SELECTEDVALUE(Actual[Name])

RETURN
SWITCH(
    TRUE(),
    _dpv = "A", "B Value" & ": " &  CALCULATE(AVERAGE(Actual[Values]),FILTER(all(Actual),Actual[Name]="B")),
    _dpv = "E", "F Value" & ": " &  CALCULATE(AVERAGE(Actual[Values]),FILTER(all(Actual),Actual[Name]="F")),
    "* No data"
 
)  

Request any modification in above measure. Thanks in advance

1 ACCEPTED SOLUTION
User232431
Helper I
Helper I

I have solved using below DAX

 

_newmeasure =
VAR _dpv = SELECTEDVALUE(Actual[Name])
VAR _et = SELECTEDVALUE(Actual[Country])
VAR _pt = SELECTEDVALUE(Actual[Period])
var _yr = SELECTEDVALUE(Actual[Year])
var _mn = SELECTEDVALUE(Actual[Month])
//VAR _en = SELECTEDVALUE(Actual[Name])

RETURN
SWITCH(
    TRUE(),
   // _dpv = "A", "B Value" & ": " & IF( (ISFILTERED(Actual[Country])||ISFILTERED(Actual[Period])||ISFILTERED(Actual[Year])||ISFILTERED(Actual[Month])), CALCULATE(AVERAGE(Actual[Values]),FILTER((Actual),Actual[Name]="B"))),
   _dpv = "A", "B Value" & ": " & CALCULATE(AVERAGE(Actual[Values]),FILTER(all(Actual),(Actual[Name]="B")
    && Actual[Country] = _et && Actual[Period] =_pt && Actual[Year] =_yr && Actual[Month] = _mn  )),
    _dpv = "E", "F Value" & ": " &  CALCULATE(AVERAGE(Actual[Values]),FILTER(all(Actual),(Actual[Name]="F")
    && Actual[Country] = _et && Actual[Period] =_pt && Actual[Year] =_yr && Actual[Month] = _mn   )),
    "* No data"
 
)
 
Thank you

View solution in original post

3 REPLIES 3
v-pnaroju-msft
Community Support
Community Support

Hi @User232431,

 

We are happy to learn that your issue has been resolved. To help others in the community, kindly mark the response that resolved your query as the accepted solution.

For any further assistance or questions, please continue to engage with the Fabric Community.

 

Best regards,
Pavan

User232431
Helper I
Helper I

I have solved using below DAX

 

_newmeasure =
VAR _dpv = SELECTEDVALUE(Actual[Name])
VAR _et = SELECTEDVALUE(Actual[Country])
VAR _pt = SELECTEDVALUE(Actual[Period])
var _yr = SELECTEDVALUE(Actual[Year])
var _mn = SELECTEDVALUE(Actual[Month])
//VAR _en = SELECTEDVALUE(Actual[Name])

RETURN
SWITCH(
    TRUE(),
   // _dpv = "A", "B Value" & ": " & IF( (ISFILTERED(Actual[Country])||ISFILTERED(Actual[Period])||ISFILTERED(Actual[Year])||ISFILTERED(Actual[Month])), CALCULATE(AVERAGE(Actual[Values]),FILTER((Actual),Actual[Name]="B"))),
   _dpv = "A", "B Value" & ": " & CALCULATE(AVERAGE(Actual[Values]),FILTER(all(Actual),(Actual[Name]="B")
    && Actual[Country] = _et && Actual[Period] =_pt && Actual[Year] =_yr && Actual[Month] = _mn  )),
    _dpv = "E", "F Value" & ": " &  CALCULATE(AVERAGE(Actual[Values]),FILTER(all(Actual),(Actual[Name]="F")
    && Actual[Country] = _et && Actual[Period] =_pt && Actual[Year] =_yr && Actual[Month] = _mn   )),
    "* No data"
 
)
 
Thank you

Hi @User232431,

 

We are delighted to know that your issue has been resolved. Kindly mark the response that resolved your query as the accepted solution. This will assist other community members facing similar challenges in finding solutions more efficiently.

Please continue to utilise the Fabric Community for any further assistance with your queries.

 

Best regards,
Pavan

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.