Forum Discussion

Arentir's avatar
Arentir
Icon for Resolver III rankResolver III
9 years ago
Solved

Create Measure based on different row (date)

Hi guys,

 

I am trying to create a report on Power BI but can't pin the right way although the goal seems very simple.

 

Here is my sample data below. I want to create a measure that will do the sum of quantity for the next day (and eventually date +2 and date +3). So I am looking somewhat to override the filter on the date and apply next day instead.

 

I simplified the sample to two dimensions but I would eventually have more (product category, supplier..)

Sample:

DateNameQuantity
01/01/2017A5
01/01/2017A5
01/01/2017B5
02/01/2017A1
02/01/2017A2
02/01/2017B2
02/01/2017B3

 

 What I am trying to achieve:

DateNameSum(Qty)Sum(Next_Day_Qty)
01/01/2017A103
01/01/2017B55
02/01/2017A3 
02/01/2017B5 

 

Thanks 

  • NextDay Totals =
    CALCULATE ( SUM ( 'Table'[Quantity] ), DATEADD ( 'Calendar'[Date], +1, DAY ) )

5 Replies

    • Sean's avatar
      Sean
      Icon for Community Champion rankCommunity Champion
      NextDay Totals =
      CALCULATE ( SUM ( 'Table'[Quantity] ), DATEADD ( 'Calendar'[Date], +1, DAY ) )
      • Arentir's avatar
        Arentir
        Icon for Resolver III rankResolver III

        Sean I believe your solution is close to what I am looking for.

         

        I have written the formulas as :

         

        Spoiler
        NextDay Total = CALCULATE(SUM('Product'[Quantity]),DATEADD('Product'[Date],1,DAY))

        Note that I am using the same table for Quantity and Date. It works like a charm with the current sample, I have tried to add one product C with non following date for test:

         

         

         

         

        It looks fine at first

        But when I filter C I get this message

         

        Fair enough, I have tried to add a calendar table relating to Product table and changed the measure to:

         

        Spoiler
        NextDay Total = CALCULATE(SUM('Product'[Quantity]),DATEADD('Calendar'[Date],1,DAY))

        The measure looks like a simple Sum(Quantity)