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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
eric98
Helper II
Helper II

Field Chronological order

Hi, 

I have an issue and you may help with it. 

Let's suppose I have a table of invoices like this :

 

invoice_numberclient_name
22012304/OCSCOCA
22012305/OCSCOCA
22012306/OCSCOCA
22012307/OCSDELL
22012309/OCSDELL
22012310/OCSDELL
22012311/OCSHP
22012312/OCSHP
22012314/OCSHP

 

Invoices number have to be in chronological order.  You can see that invoices number 22012308/OCS and 22012313/OCS are missing. 

 

Do you know how to detect if the chronological order is break or not ? Or even if it possible to do it in Power BI.

 

Thanks for your help.

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

Hi @eric98 ,

 

Please check the formula:

is break =
VAR last_invoice =
    CALCULATE (
        MAX ( 'Table'[invoice_number] ),
        FILTER (
            'Table',
            'Table'[client_name] = EARLIER ( 'Table'[client_name] )
                && 'Table'[invoice_number] < EARLIER ( 'Table'[invoice_number] )
        )
    )
VAR last_number =
    LEFT ( last_invoice, 8 ) + 0
VAR current_number =
    LEFT ( 'Table'[invoice_number], 8 )
RETURN
    IF ( last_number = 0, 0, IF ( current_number - last_number = 1, 0, 1 ) )

vjaywmsft_0-1654591109873.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

Hi @eric98 ,

 

Please check the formula:

is break =
VAR last_invoice =
    CALCULATE (
        MAX ( 'Table'[invoice_number] ),
        FILTER (
            'Table',
            'Table'[client_name] = EARLIER ( 'Table'[client_name] )
                && 'Table'[invoice_number] < EARLIER ( 'Table'[invoice_number] )
        )
    )
VAR last_number =
    LEFT ( last_invoice, 8 ) + 0
VAR current_number =
    LEFT ( 'Table'[invoice_number], 8 )
RETURN
    IF ( last_number = 0, 0, IF ( current_number - last_number = 1, 0, 1 ) )

vjaywmsft_0-1654591109873.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
NickolajJessen
Solution Sage
Solution Sage

Correct


So I would make the addition of the first element with the index.

And I would be able to have where the chain became broken.


Not with this setup. is that something you need as well?

Should I be able to know how many chain are broked by count them ?



Yeah I would like to have it.

I'm thinking instead of the text "good so far" and "chain broken", I would use "1" for "chain broken" and "0" for "good so far", like that I will just make the sum of "1"

But like you said, with this setup, the result are not good.

Here you go 😊!

NickolajJessen_0-1654233481501.png

Let me know if you have any more questions 😊

NickolajJessen
Solution Sage
Solution Sage

Uhmm, well you do have an incremental number so you can do something like this in power query:

NickolajJessen_0-1654170441408.png

 

So I would make the addition of the first element with the index.

And I would be able to have where the chain became broken.

Should I be able to know how many chain are broked by count them ?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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