Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Fragmaticx
Frequent 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 need something like, if selectedmeasure is OperationalDate then 

   BaseData[ShipmentPeriod] <> BaseData[OperationalPeriod]
elseif 

Selectedmeasure is ShipmentPeriod then
 BaseData[OperationalPeriod] <>    BaseData[ShipmentPeriod]


Lastmile Cost - Different Period = 
                CALCULATE(
                    SUMX(BaseData, BaseData[AmountDKK]),
                    FILTER(
                        BaseData,
                        BaseData[Type] = 2 &&
                        BaseData[TransportType] = 1 && 
                        BaseData[ShipmentPeriod] <> BaseData[OperationalPeriod]
                    )
                )

 

but I dont know how to do it?

4 REPLIES 4
Fragmaticx
Frequent 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] ) )





 

OperationalPeriodShipmentPeriodAmountDKKTypeCustomerTransportType
01-08-202501-08-20251002Dennis1
01-07-202501-08-20251502Dennis1

 

 

 

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,


 

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]
    )
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
techies
Super User
Super User

Hi @Fragmaticx As i understand, you can try using ISSELECTEDMEASURE where you want change depending on measures shipment based, operational based

 

Please share sample datasets to test 

 

 

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
FBergamaschi
Solution Sage
Solution Sage

I am unsure as to what you are trying to do

 

Please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even is just a subset of the original tables, must cover your issue or question completely. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

 

Need help uploading data? click here

 

Want faster answers? click here

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.