Forum Discussion

vytas's avatar
vytas
Helper I
6 years ago
Solved

Min/Max Dates

Hi, 

I have virtual table :

Unpaid Invoices =

FILTER (

    ADDCOLUMNS (

        SUMMARIZE (

            Debt;

            Debt[DocumentNr];

            Debt[CompanyNo];

            Debt[PaymentDay]

        );

        "Saldo"; CALCULATE ( SUM ( Debt[Debt] ) );

        "InvoiceDate"; CALCULATE ( MAX ( Debt[InvoiceDate] ) )

    );

    [Saldo] > 0

)

 

Result is :

SaldoInvoiceDateDocumentNrCompanyNoPaymentDay
117.092020-02-1811258872020-05-28
44.042020-02-0521258872020-05-15
50.322020-04-2731258872020-01-08
90.052020-03-3141258872020-03-09
202.032020-04-2751258872020-01-14
442.252020-04-1661258872020-05-16
574.032020-04-1671258872020-05-16
167.672020-04-1681258872020-05-16
133.022020-04-1691258872020-05-16
110.22020-04-17101258872020-05-17
51.032020-04-20111258872020-05-20
149.762020-04-20121258872020-05-20
500.342020-04-20131258872020-05-20
45.512020-04-22141258872020-05-22
102.742020-04-22151258872020-05-22
102.532020-04-22161258872020-05-22
71.392020-04-22171258872020-05-22
67.272020-04-22181258872020-05-22
56.612020-04-23191258872020-05-23
169.822020-04-23201258872020-05-23
177.882020-04-23211258872020-05-23
1842020-04-23221258872020-05-23
34.252020-04-24231258872020-05-24
70.62020-04-28241258872020-05-28

 

How could i write a measure which gives me difference in days between max and min invoice date

  • Hi vytas 

     

    Try something like this.

    Measure = 
    VAR __tbl =
        FILTER (
            ADDCOLUMNS (
                SUMMARIZE (
                    Debt;
                    Debt[DocumentNr];
                    Debt[CompanyNo];
                    Debt[PaymentDay]
                );
                "Saldo"; CALCULATE ( SUM ( Debt[Debt] ) );
                "InvoiceDate"; CALCULATE ( MAX ( Debt[InvoiceDate] ) )
            );
            [Saldo] > 0
        )
    VAR __min = MINX( __tbl, [InvoiceDate] )
    VAR __max = MAXX( __tbl, [InvoiceDate] )
    RETURN 
        __max - __min 

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn

     

3 Replies