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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Get the number of Orders that have had their dates modified

Hello everyone,
I have an orders history table where orders are logged in it at the end of each day and I want to calculate the number of orders that have had their Delivery date changed between two selected history dates. In the sample below the measure should return 2.

Order IdDelivery dateHistory date
2056730/06/202330/06/2023
2056619/06/202330/06/2023
2056520/06/202330/06/2023
2056720/06/202325/06/2023
2056620/06/202325/06/2023
2056520/06/202325/06/2023

I have tried the followinf DAX measure but it's not working since I can't use CALCULATE in a True/False statement.

 

Date modified = 
VAR _RefDate =
    MIN ( 'Reference Date'[Date] )
VAR _CompDate =
    MIN ( 'Comparaison Date'[Date] )
VAR FilteredIDs =
    CALCULATETABLE (
        VALUES ( 'Orders history'[Order Id] ),
        'Orders history'[History date] = _RefDate
    )
VAR ModifiedIDs =
    CALCULATETABLE (
        VALUES ( 'Orders history'[Order Id] ),
        'Orders history'[History date] = _CompDate
            && 'Orders history'[Order Id]
                IN FilteredIDs
                    && 'Orders history'[Delivery date]
                        <> CALCULATE (
                            MAX ( 'Orders history'[Delivery date] ),
                            ALLEXCEPT ( 'Orders history', 'Orders history'[Delivery date] ),
                            'Orders history'[History date] = _RefDate
                        )
    )
RETURN
    COUNTROWS ( ModifiedIDs )

 

 I could really use your help and thank you in advance.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Date modified =
VAR _RefDate =
    MIN ( 'Reference Date'[Date] )
VAR _CompDate =
    MIN ( 'Comparaison Date'[Date] )
RETURN
    SUMX (
        VALUES ( 'Orders history'[Order Id] ),
        INT (
            COUNTROWS (
                CALCULATETABLE (
                    VALUES ( 'Orders history'[Delivery date] ),
                    'Orders history'[History date] IN { _RefDate, _CompDate }
                )
            ) > 1
        )
    )

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Date modified =
VAR _RefDate =
    MIN ( 'Reference Date'[Date] )
VAR _CompDate =
    MIN ( 'Comparaison Date'[Date] )
RETURN
    SUMX (
        VALUES ( 'Orders history'[Order Id] ),
        INT (
            COUNTROWS (
                CALCULATETABLE (
                    VALUES ( 'Orders history'[Delivery date] ),
                    'Orders history'[History date] IN { _RefDate, _CompDate }
                )
            ) > 1
        )
    )
Anonymous
Not applicable

I've just tried it and it works! Thank you very much!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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