Forum Discussion
Calculating Average excluding MEASURE data
Hello - Trying to develop a measure excluding certain data.
| Project | PF | Avg PF | Exclude? |
| Project 1 | 2.47 | 2.20 | 1 |
| Project 2 | 1.54 | 2.20 | |
| Project 3 | 2.59 | 2.20 |
Currently Average is calculated correctly [2.47 + 1.54 + 2.59] / 3 = 2.20
But i wanted to ignore Project 1 in the average calculation (as exclude = 1). Hence i want the average PF to be [1.54 +2.59] = 2.07
I am currently using the below formula, but it is still considering all 3 projects
Avg PF =
I am trying to show a CHART (Column-Line) visual, and hence i need to show all the 3 x Projects PF values in columns, but the average line should be based on 2 x Projects.
Kindly note "Exclude" is a measure based on=
Appreciate the support
Hi,
Like this?
___AvgforNonExcluded = CALCULATE( AVERAGE('Table'[PF]), FILTER(ALL('Table'),'Table'[Exclude]=BLANK()))As seen here:
Link to file.
Please mark as solution if so. Thumbs up for the effort are appreciated.
Kind regards,
Steve.hackfifi
I forgot to remove the variable, as it always stays static, please check now:Avg PF (Excluded) = AVERAGEX( FILTER(ALL(Table2[Project]),[Exclude] <> 1), [PF] )________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
12 Replies
- VijayPCommunity Champion
- hackfifiHelper V
VijayP - can you copy / paste the code please?
Also FYI -
"PF" is a measure
i have a filter for selection of projects i.e. Projects_Alias
and also a filter for selection of refrence projects i.e. 'Ref Project'. The list of projects is the same of both filters
But when a project is selected from 'Ref Project', it calculates a "1" for the "exclude measure"
- VijayPCommunity Champion
hackfifi
create PF as a column and use this measure to get the resultIF you want use PF As measure Change 'Table'[PF] to [PF] and remaining formula will be same
AVG PF2 =
VAR totalpf = CALCULATE(SUM('Table'[PF]),All('Table'))
VAR prjct1pf = CALCULATE(SUM('Table'[PF]),
FILTER(ALL('Table'),'Table'[Project]=SELECTEDVALUE('Table'[Project])))VAR balance = totalpf-prjct1pf
VAR cnt = CALCULATE(COUNT('Table'[Project]),All('Table'))
VAR selectcnt = CALCULATE(COUNT('Table'[Proejct]),
FILTER(ALL('Table'),'Table'[Project]=SELECTEDVALUE('Table'[Project])))
VAR cntbalance = cnt-selectcnt
RETURN
Divide(balance,cntbalance,0)
- Ashish_MathurSuper User
Hi,
Does this measure work? Drag this measure to a card visual.
=averagex(filter(values(data[project]),data[exclude?]<>1),[pf])
Hope this helps.