Forum Discussion

sanimesa's avatar
sanimesa
Post Prodigy
8 years ago
Solved

FIRSTDATE and LASTDATE functions broken?

Has anything changed with the Firstdate and Lastdate functions in the May release?

 

 

I have a date slicer with the invoice date added to it. To display the slicer selection, I use the below measure:

 

Invoice Date Selected = "Reporting Period: " & FORMAT(FIRSTDATE(InvoiceTable[InvoiceDate]), "MMMM DD, YYYY") & " - " & FORMAT(LASTDATE(Reporting_JSG_ConsolidatedOrders[InvoiceDate]), "MMMM DD, YYYY")

 

It used to work before but now I get an error:

A date column containing duplicate dates was specified in the call to function 'FIRSTDATE'. This is not supported.

 

 

 

  • Anonymous's avatar
    Anonymous
    8 years ago

    HI sanimesa,

     

    I'm not so sure why firstdate and lastdate function not works on your side. (I test with last version without any issue)

    Can you please share pbix file to test?


    In addition, you can also try to use below formula to instead:

    Invoice Date Selected =
    "Reporting Period: "
        & FORMAT (
            MINX ( ALLSELECTED ( InvoiceTable[InvoiceDate] ), [InvoiceDate] ),
            "MMMM DD, YYYY"
        )
        & " - "
        & FORMAT (
            MAXX (
                ALLSELECTED ( Reporting_JSG_ConsolidatedOrders[InvoiceDate] ),
                [InvoiceDate]
            ),
            "MMMM DD, YYYY"
        )
    

    Regards,

    Xiaoxin Sheng

  • Anonymous's avatar
    Anonymous
    8 years ago

    HI sanimesa,

     

    After checking your pbix file, I found it similar as @KHorseman said, 'firstdate' and 'lastdate' function not works if your date table contains duplicate records.


    I modify my formula and current it can works on your scenario, please take a look at below formula:

    Invoice Date Selected =
    "Reporting Period: "
        & FORMAT (
            MINX ( VALUES ( Sheet2[InvoiceDate] ), [InvoiceDate] ),
            "MMMM DD, YYYY"
        )
        & " - "
        & FORMAT (
            MAXX ( VALUES ( Sheet2[InvoiceDate] ), [InvoiceDate] ),
            "MMMM DD, YYYY"
        )
    

     

    Regards,
    Xiaoxin Sheng

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI sanimesa,

     

    I'm not so sure why firstdate and lastdate function not works on your side. (I test with last version without any issue)

    Can you please share pbix file to test?


    In addition, you can also try to use below formula to instead:

    Invoice Date Selected =
    "Reporting Period: "
        & FORMAT (
            MINX ( ALLSELECTED ( InvoiceTable[InvoiceDate] ), [InvoiceDate] ),
            "MMMM DD, YYYY"
        )
        & " - "
        & FORMAT (
            MAXX (
                ALLSELECTED ( Reporting_JSG_ConsolidatedOrders[InvoiceDate] ),
                [InvoiceDate]
            ),
            "MMMM DD, YYYY"
        )
    

    Regards,

    Xiaoxin Sheng