locked
Sum of Max Time Period Selected RRS feed

  • 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

Answers

  • 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,

    Glad to hear that your issue got solved. Please mark your reply as answer, which will help other people find the solution easily.

    Best Regards, 
    Angelia 

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 1, 2017 1:49 AM