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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CSpina
Helper III
Helper III

Calculate Colunm get last invoice number from previous month

Hi, people.

 

I need to create a "caculated column", if possible" with the last invoice number from previous month.

 

Example Data

 

let

    Fonte = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fY9LCsMwDAWvUrwO+EmyPu5VQu5/jdh1MRSU7rQY5o3Os5CJG5ejULCr0bjYK7wymF7AGyjX8cMZ2H1yqIiUk+3jv77FmbTWJieJj9V1RpF31T4xaKLbWLQeTI+2YbEVh4jPKGe2jY1NrK8TWwi1b5uNgKe2jYUC0LTtugE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustomerID = _t, #"Invoice Number" = _t, Date = _t]),

    #"Tipo Alterado" = Table.TransformColumnTypes(Fonte,{{"CustomerID", Int64.Type}, {"Invoice Number", Int64.Type}, {"Date", type datetime}})

in

    #"Tipo Alterado"

 

 Any ideias?

 

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

Hi, @CSpina 

You can take a try the following formula.

 

Result = 
    CALCULATE (
        MAX ( Query1[Invoice Number] ),
        FILTER (
            Query1,
            Query1[CustomerID] = EARLIER ( Query1[CustomerID] )
                && Query1[Date] <EARLIER(Query1[Date])
        )
    )

29.png

 

If it doesn't meet your requirement,please share your expected result in excel.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @CSpina 

You can take a try the following formula.

 

Result = 
    CALCULATE (
        MAX ( Query1[Invoice Number] ),
        FILTER (
            Query1,
            Query1[CustomerID] = EARLIER ( Query1[CustomerID] )
                && Query1[Date] <EARLIER(Query1[Date])
        )
    )

29.png

 

If it doesn't meet your requirement,please share your expected result in excel.

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.