Forum Discussion

Fragmaticx's avatar
Fragmaticx
Frequent Visitor
11 months ago
Solved

CalculationGroups - switch between dates

Hi  I have a model where I use calculaton groups to switch between dates. Lets say its a Order Date and Delivery Date - and I want to make a calculation based of the 2 dates.   I think i ...
  • techies's avatar
    techies
    11 months ago

    Hi Fragmaticx please try this

     

    Lastmile Cost - Different Period =
    VAR CurrentCalcItem = SELECTEDVALUE ( 'DateToUse'[Calculation group column] )
    RETURN
    CALCULATE (
        SUM ( BaseData[AmountDKK] ),
        BaseData[Type] = 2,
        BaseData[TransportType] = 1,
        SWITCH (
            CurrentCalcItem,
            "OperationalPeriod", BaseData[ShipmentPeriod] <> BaseData[OperationalPeriod],
            "ShipmentPeriod", BaseData[OperationalPeriod] <> BaseData[ShipmentPeriod]
        )
    )