Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate sum depending on slicer

Hi 

I want to calculate a sum of a value depending on the lowest and highest value chosen on a slicer. 

 

The slicer is showing all dates from 2019 and when i pick e.g. 16/03/2019 i want a meassure that sums the revenue for that day. 

 

My data is sorted like this: 

DateCustomerRevenue
01-01-2019A1682
01-01-2019B4021
02-01-2019A1130
02-01-2019B2706
  
18-11-2019A2264
18-11-2019B2091

 

So if i on my slicer chose 02-01-2019 as the lowest date and 18-11-2019 as my highest date i would like two meassures. 
Revenue for lowest date: 1.682 + 4.021 = 5.703

Revenue for higest date: 2.264 + 2.091 = 4.355 

The end result is that i need to calculate the difference between theese two meassures 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

    Cerate two different measure to calculate Lowest date revenue and Highest Date revenue as like below,

    Revenue_Highest =
    VAR Maximum_date = MAX('Table'[Date])
    RETURN
    CALCULATE(SUM('Table'[Revenue]),'Table'[Date]=Maximum_date)
     
    Revenue_Lowest =
    VAR Minimum_date = MIN('Table'[Date])
    RETURN
    CALCULATE(SUM('Table'[Revenue]),'Table'[Date]=Minimum_date)
     
    It will wor as you expected,  find the below screen shot FYR.

    Dateset:
     
    Selection From Jan 1st to Nov-18:
    Selection From Jan 26th to Nov-18:
     


    Best Regards,
    Mail2inba4

    If this post 
    helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Cerate two different measure to calculate Lowest date revenue and Highest Date revenue as like below,

    Revenue_Highest =
    VAR Maximum_date = MAX('Table'[Date])
    RETURN
    CALCULATE(SUM('Table'[Revenue]),'Table'[Date]=Maximum_date)
     
    Revenue_Lowest =
    VAR Minimum_date = MIN('Table'[Date])
    RETURN
    CALCULATE(SUM('Table'[Revenue]),'Table'[Date]=Minimum_date)
     
    It will wor as you expected,  find the below screen shot FYR.

    Dateset:
     
    Selection From Jan 1st to Nov-18:
    Selection From Jan 26th to Nov-18:
     


    Best Regards,
    Mail2inba4

    If this post 
    helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much! It worked perfectly!