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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
EduardoSolaft
Frequent Visitor

Calculate: 2 different Dates with different Criteria and Relationships.

Hi,

 

My calculation is very easy to do in Excel, but it's been hard to do it in DAX.

 

I need to calculate on each Month End the Orders that haven't been invoiced yet, to support my Backlog calculation.

In my Invoice Fact Table I have "Invoice Date" (active relationship with Calendar Table) and "Order Date" (inactive relationshp with calendar).

 

In Excel I can work it out with a simple SUMIFS using the following criteria:

Invoice Date > End of Month (Invoice Date must be in the future, to make sure it haven't been invoiced yet).

Order Date <= End of Month (Order Date must be in the past, to make sure it exists).

 

The image below shows an example of how it works:

Help Community.PNG

 

I need to create a measure using CALCULATE, identifying the LAST DAY of the Date Context, with 2 filters:

Filter 1: Invoice Date > Last Day of filter context (where Invoice Date has active relationship with Calendar Table),

Filter 2: Order Date <= Last Day of filter context (where Order Date has inactive relationship with Calendar Table).

 

I'd appreciate the help of the community.

 

Kind Regards,

Eduardo Sousa.

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @EduardoSolaft ,

Please try this measure:

Backlog = 
CALCULATE (
    SUM ( 'Table'[Sales] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Invoice Date] > MAX ( 'Calendar'[End of Month] )
            && 'Table'[Order Date] <= MAX ( 'Calendar'[End of Month] )
    )
)

vcgaomsft_0-1668135869522.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @EduardoSolaft ,

Please try this measure:

Backlog = 
CALCULATE (
    SUM ( 'Table'[Sales] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Invoice Date] > MAX ( 'Calendar'[End of Month] )
            && 'Table'[Order Date] <= MAX ( 'Calendar'[End of Month] )
    )
)

vcgaomsft_0-1668135869522.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Hi,

 

It works well!

 

I've just changed the ALL to ALLSELECTED, because I still need to use a Slicer.

 

Thank you!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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