Forum Discussion

GordyM1's avatar
GordyM1
Regular Visitor
4 years ago
Solved

If AND formula help

Hi,   I have some data where I want to identify a break in the sequence of the data. I show the Excel formula that does this but I would like to have this calculation in Power Query but not sure ho...
  • v-yanjiang-msft's avatar
    4 years ago

    Hi GordyM1 ,

    According to your description, here's my solution.

    1.Create a index column.

    2.Create a custom column.

    Custom = if [Index]=0 then "" else if [ItemID]=Table.SelectRows(#"Added Index",(x)=>x[Index]=[Index]-1)[ItemID]{0} and Table.SelectRows(#"Added Index",(x)=>x[Index]=[Index]-1)[MSQ]{0}>0 and [FY]-Table.SelectRows(#"Added Index",(x)=>x[Index]=[Index]-1)[FY]{0}>1 then "x" else""

    Or you can create a calculated column in DAX.

    Column =
    VAR _T =
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    RETURN
        IF (
            'Table'[ItemID] = MAXX ( _T, 'Table'[ItemID] )
                && MAXX ( _T, 'Table'[MSQ] ) > 0
                && 'Table'[FY] - MAXX ( _T, 'Table'[FY] ) > 1,
            "x",
            ""
        )
    

    Both methods can get the expected result.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.