Forum Discussion
Calculate an average with date filter
- 6 years ago
Hi Pedro77000 ,
We can create a measure as below.
Measure = VAR SUMA = CALCULATE ( SUM ( 'Table'[value] ), FILTER ( ALL ( 'Table' ), 'Table'[date] <= MAX ( 'date'[Date] ) ) ) VAR COUNTM = CALCULATE ( DISTINCTCOUNT ( 'Table'[YearMOnth] ), FILTER ( ALL ( 'Table' ), 'Table'[date] <= MAX ( 'date'[Date] ) ) ) RETURN DIVIDE ( SUMA, COUNTM )Also you can find the pbix as attached.
- 6 years ago
Hi Pedro77000 ,
To use ALLEXCEPT instead of ALL should work.
FILTER ( ALLEXCEPT ( 'Table','Table'[region] ), 'Table'[date] <= MAX ( 'date'[Date] ) )If it doesn't meet your requirement, Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
Hi Pedro77000 ,
We can create a measure as below.
Measure =
VAR SUMA =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER ( ALL ( 'Table' ), 'Table'[date] <= MAX ( 'date'[Date] ) )
)
VAR COUNTM =
CALCULATE (
DISTINCTCOUNT ( 'Table'[YearMOnth] ),
FILTER ( ALL ( 'Table' ), 'Table'[date] <= MAX ( 'date'[Date] ) )
)
RETURN
DIVIDE ( SUMA, COUNTM )
Also you can find the pbix as attached.
- Pedro770006 years agoFrequent Visitor
Good morning v-frfei-msft !!
Thank you very much for this reply.
The solution works well. But this average I cannot have it by region, I believe because of the filter ALL.
The average for the total is good but when I split by region, it's the same overall average that appears in front of each region.- v-frfei-msft6 years agoCommunity Support
Hi Pedro77000 ,
To use ALLEXCEPT instead of ALL should work.
FILTER ( ALLEXCEPT ( 'Table','Table'[region] ), 'Table'[date] <= MAX ( 'date'[Date] ) )If it doesn't meet your requirement, Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
- Pedro770006 years agoFrequent Visitor
Thank you so much Franck ! that works well ! even if the disadvantage of ALLEXCEPT is having to enter the fields of all dimension tables.
- Anonymous6 years agoNot applicable
Hi Pedro77000
Try changing ALL to ALLSELECTED and then it should carry your filters through.
---
Please hit the "Accept as Solution" button if my post answered your question! If my post was helpful please consider giving it a "Thumbs Up."