Forum Discussion
Fragmaticx
11 months agoFrequent Visitor
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 ...
- 11 months ago
Hi Fragmaticx please try this
Lastmile Cost - Different Period =VAR CurrentCalcItem = SELECTEDVALUE ( 'DateToUse'[Calculation group column] )RETURNCALCULATE (SUM ( BaseData[AmountDKK] ),BaseData[Type] = 2,BaseData[TransportType] = 1,SWITCH (CurrentCalcItem,"OperationalPeriod", BaseData[ShipmentPeriod] <> BaseData[OperationalPeriod],"ShipmentPeriod", BaseData[OperationalPeriod] <> BaseData[ShipmentPeriod]))
Fragmaticx
11 months agoFrequent Visitor
Hi everybody,
This is a small sample set.
I have a calculation group: DateToUse
Item 1:
SELECTEDMEASURE ()
Item 2:
CALCULATE ( SELECTEDMEASURE (), USERELATIONSHIP ( BaseData[ShipmentPeriod], 'DateTable'[Date] ) )
| OperationalPeriod | ShipmentPeriod | AmountDKK | Type | Customer | TransportType |
| 01-08-2025 | 01-08-2025 | 100 | 2 | Dennis | 1 |
| 01-07-2025 | 01-08-2025 | 150 | 2 | Dennis | 1 |
Lastmile Cost - Different Period =
CALCULATE(
SUMX(
BaseData,
BaseData[AmountDKK]
),
FILTER(
BaseData,
BaseData[Type] = 2 &&
BaseData[TransportType] = 1 &&
BaseData[ShipmentPeriod] <> BaseData[OperationalPeriod]
)
)
I expect it to show if ShipmentPeriod is selected then it should be 0 since both lines are within that period, and if OperationalPeriod is selected it should show 150, since they are 01-07-2025.
I appriciate your help,
- techies11 months agoSuper User
Hi Fragmaticx please try this
Lastmile Cost - Different Period =VAR CurrentCalcItem = SELECTEDVALUE ( 'DateToUse'[Calculation group column] )RETURNCALCULATE (SUM ( BaseData[AmountDKK] ),BaseData[Type] = 2,BaseData[TransportType] = 1,SWITCH (CurrentCalcItem,"OperationalPeriod", BaseData[ShipmentPeriod] <> BaseData[OperationalPeriod],"ShipmentPeriod", BaseData[OperationalPeriod] <> BaseData[ShipmentPeriod]))