# Sum of Max Time Period Selected • ### Question

• HI ,

I am using a  timeline slicer where the user selects the time range in powerbi.

﻿I now need to calculate the sum of maximum and minimum months selected.Created two calculations which gives Maxdate and MInDate as measures:

MaxDate = CALCULATE(MAX(Date),ALLSELECTED(Date))

MinDate = CALCULATE(MIN(Date),ALLSELECTED(Date))

Now  i am trying to get the sum of maximum month using below measure:

MaxMonthSales =
IF (
HASONEVALUE (Date[Date]),
CALCULATE (
SUM(Sales),
FILTER(
ALL (Date),
YEAR(Date[Date]) =  YEAR([MaxDate]) &&
MONTH(Date[Date]) = MONTH([MaxDate])
)
),
BLANK ()
)

The measure is not returning any error but it showing same number irrespective of the timeperiod selected.

Where am i going wrong?

Friday, April 28, 2017 8:25 AM

• I was able to solve the problem:

Instead of comparing with max and min dates directly , i created below measure:

MaxMonthSales =
CALCULATE (
SUM (Sales),
FILTER (
ALL (Date ),
YEAR ( Date[Date]) = YEAR ( MAX ( Date[Date] ) )
&&  MONTH (Date[Date]) = MONTH ( MAX ( Date[Date] ) )
))

Friday, April 28, 2017 9:18 AM

### All replies

• I was able to solve the problem:

Instead of comparing with max and min dates directly , i created below measure:

MaxMonthSales =
CALCULATE (
SUM (Sales),
FILTER (
ALL (Date ),
YEAR ( Date[Date]) = YEAR ( MAX ( Date[Date] ) )
&&  MONTH (Date[Date]) = MONTH ( MAX ( Date[Date] ) )
))

Friday, April 28, 2017 9:18 AM
• Hi Navyasree,