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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
vytas
Helper I
Helper I

Calendar Date Context

Hello , 

 There is a measure

Unpaid Invoice Days = 
VAR _tbl =
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                Debt;
                Debt[DocumentNo];
                Debt[KeyCode];
                Debt[PaymentDate]
            );
            "Saldo"; CALCULATE ( SUM ( Debt[Amount] ) );
            "InvoiceDate"; CALCULATE ( MAX ( Debt[DocumentDate] ) ) //For knowing which Date Invoice is unpaid 
        );
        [Saldo] > 0 // to filter Unpaid Invoices
    )
VAR _min = MINX ( _tbl; [InvoiceDate] )
VAR _max = MAXX ( _tbl; [InvoiceDate] )
RETURN
    CALCULATE (
        DATEDIFF ( _min; _max; DAY );
        FILTER (
            ALL ( 'Calendar'[Date] );
            'Calendar'[Date] >= MAX ( 'Calendar'[Date] )
        )
    )

 

It working fine, but when i put it with Calendar[Date] column it filter's my _tbl rows. I tried to wrap DATEDIFF ( _min; _max; DAY ) function with CALCULATE FILTER ALL pattern, but it dont work. What is wrong ?

 

pbix Sample file - https://1drv.ms/u/s!Ag3StL_v1twMoVIBrE0WPgoN3QT4?e=4MbQ5h

 

Thank You

3 REPLIES 3
dax
Community Support
Community Support

Hi @vytas , 

Did you have relationship between two tables or how did you design you table? If possible, could you please inform me more detailed information(such as your expected output and your sample data (by OneDrive for Business))? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @dax , 

 

 There is sample data file. All information is in there. https://1drv.ms/u/s!Ag3StL_v1twMoVIBrE0WPgoN3QT4?e=3vAIMv 

 

Thank You in advance

Greg_Deckler
Community Champion
Community Champion

Difficult to tell. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.