Forum Discussion
Issue with Matrix and AVG calulcation
- 5 years ago
Hi baneworth ,
Create a measure as below:
Measure 2 = var _dates=CALCULATETABLE(VALUES('Date'[Date]),FILTER(ALL('Date'),MONTH('Date'[Date])=MONTH(MAX('Date'[Date]))&&YEAR('Date'[Date])=YEAR(MAX('Date'[Date]))&&'Date'[IsWeekday]=TRUE())) var _days=CALCULATE(COUNTROWS(_dates),FILTER(_dates,MONTH('Date'[Date])=MONTH(MAX('Date'[Date]))&&YEAR('Date'[Date])=YEAR(MAX('Date'[Date])))) var _number=CALCULATE(COUNT('Calculated Table'[Index]),FILTER(ALL('Calculated Table'),'Calculated Table'[Group]=MAX('Calculated Table'[Group])&&'Calculated Table'[Date] in _dates)) Return DIVIDE(_number,_days)+0And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
Hi baneworth ,
Hope you are doing good.
I have looked into your pbix file. Try to create measure instead of plotting direct column (Count of Index) into values.
test =
IF (
COUNT ( 'Calculated Table'[Index] ) > 0,
COUNT ( 'Calculated Table'[Index] ),
0
)
If this helps then please mark this as solution so that others can refer to it as well.
Hey Angith_Nair
That worked perfect!
But how would i use this measure to get the AVG for month?
Current AVG Formula:
Sorry if this might seem obvious.
BR
- Angith_Nair5 years ago
Continued Contributor
You can use the following measure...
Average test module = VAR AverageValue = AVERAGEX ( FILTER ( 'Date', 'Date'[IsWeekday] = TRUE () ), CALCULATE ( DISTINCTCOUNT ( 'Calculated Table'[Index] ) ) ) VAR SelectedGroup = SELECTEDVALUE ( 'Calculated Table'[Group] ) RETURN IF ( ISBLANK ( SelectedGroup ) && ISBLANK ( AverageValue ), 0, AverageValue )If this helps then please mark it as a solution.
- baneworth5 years ago
Helper III
Dear Angith_Nair
Unfortunately the AVG values for Jan Feb & Mar did not change throughout the group names.
Sorry if i did not express myself clear enough, i would need to take the days without modules as "0" into the AVG calculcation.
example:
current: which would give me AVG of 7
MO TU WE TH FR
6 7 7 8
needed for AVG calc: which would give me AVG of 5.6
MO TU WE TH FR
6 7 0 7 8
Creating the monthly AVG including the 0 days would be needed.
BR
Appreciate your time!
- v-kelly-msft5 years ago
Community Support
Hi baneworth ,
Create a measure as below:
Measure 2 = var _dates=CALCULATETABLE(VALUES('Date'[Date]),FILTER(ALL('Date'),MONTH('Date'[Date])=MONTH(MAX('Date'[Date]))&&YEAR('Date'[Date])=YEAR(MAX('Date'[Date]))&&'Date'[IsWeekday]=TRUE())) var _days=CALCULATE(COUNTROWS(_dates),FILTER(_dates,MONTH('Date'[Date])=MONTH(MAX('Date'[Date]))&&YEAR('Date'[Date])=YEAR(MAX('Date'[Date])))) var _number=CALCULATE(COUNT('Calculated Table'[Index]),FILTER(ALL('Calculated Table'),'Calculated Table'[Group]=MAX('Calculated Table'[Group])&&'Calculated Table'[Date] in _dates)) Return DIVIDE(_number,_days)+0And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!