Forum Discussion

dirkkoch's avatar
dirkkoch
Helper III
5 years ago
Solved

Dynamic calculation along time period

Hi all, I would need support with the following issue (see Screenshot attached). I have 2 tables (Inbound & Outbound) which are both related to a Calendar table (one to many relation). As a result...
  • v-janeyg-msft's avatar
    v-janeyg-msft
    5 years ago

    Hi, dirkkoch 

     

    You need to create three columns and a measure in calendar table. Because today is the 19th, the data has changed a bit.

    Like this:

    Column =
    VAR a =
        CALCULATE (
            COUNT ( 'Inbound table'[Stock location] ),
            FILTER ( ALL ( 'Inbound table' ), 'Inbound table'[Inbound Date] <= TODAY () ),
            'Inbound table'[Stock location] = "Location 1"
        )
    VAR b =
        SUMX (
            FILTER ( 'Calendar table', [Date ] <= EARLIER ( 'Calendar table'[Date ] ) ),
            [ColumnINBOUND]
        )
    VAR c =
        SUMX (
            FILTER ( 'Calendar table', [Date ] <= EARLIER ( 'Calendar table'[Date ] ) ),
            [ColumnOUTBOUND]
        )
    RETURN
        a + b - c
    
    Measure = IF(MAX('Calendar table'[Date ])<TODAY(),0,1)

    If it doesn’t solve your problem, please feel free to ask me.

     

    Best Regards

    Janey Guo

     

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

  • v-janeyg-msft's avatar
    v-janeyg-msft
    5 years ago

    Hi, dirkkoch 

     

    You can create a column.

    Like this:

    Column =
    VAR a =
        MAXX (
            FILTER (
                'Calendar table',
                [Relative Week] = EARLIER ( 'Calendar table'[Relative Week] )
            ),
            [Date ]
        )
    VAR b =
        MAXX ( FILTER ( 'Calendar table', [Date ] = a ), [Total Preview Day] )
    RETURN
        b
    

    Best Regards

    Janey Guo

     

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

  • v-janeyg-msft's avatar
    v-janeyg-msft
    5 years ago

    Hi, dirkkoch 

     

    You need to create a measure,then put it to the card visual. 

    Like this:

    Measure 2 = var a=MAX('Calendar table'[Relative Week])
    return CALCULATE(MAX('Calendar table'[Column]),'Calendar table'[Relative Week]=a)

    If you can give me kudos as a reward, I will be very happy.😊

     

    Best Regards

    Janey Guo