Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

missing sequential number by date

Hi Newbie here   I have the following data:   Journal Table Date Journal Number 11/05/2018 JN100 11/05/2018 JN200 11/05/2018 JN400 12/05/2018 JN100 12/05/2018 JN300 12...
  • sturlaws's avatar
    sturlaws
    6 years ago

    it makes more sense ğŸ™‚

     

    With the code you are using, if you want to avoid having the date change marked as a gap, you need a way to determine the last journal number. And I imagine that the number of journals will be increasing, so you will have to determine the number of journals per date. 

    I know it contains date, but this is how I would do it.

    Column =
    VAR _currentDate =
        CALCULATE ( SELECTEDVALUE ( journals3[Entry passed date] ) )
    VAR _currentTransaction =
        CALCULATE ( SELECTEDVALUE ( journals3[Transaction Reference Number - Copy.2] ) )
    VAR _maxTransaction =
        CALCULATE (
            MAX ( journals3[Transaction Reference Number - Copy.2] ),
            FILTER ( ALL ( journals3 ), journals3[Entry passed date] = _currentDate )
        )
    RETURN
        IF (
            COUNTROWS (
                FILTER (
                    ALL ( journals3 ),
                    _currentDate = journals3[Entry passed date]
                        && _currentTransaction + 1 = journals3[Transaction Reference Number - Copy.2]
                )
            ) = 0
                && _currentTransaction < _maxTransaction,
            "Journal Reference Gap",
            "N/A"
        )
    

     

    There is 1 other option. If you are absolutely sure the rows is loaded in the correct order, you can set an index column in Power Query, and use that to check if the row with the next index number is the row where journal number is 001. 

     

    But either way, you will have a potential issue with what if the last journal is missing.