Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Highlight 7th data point based on consecutive increases or decreases in line chart in PowerBI

Hi There, I've Batch table where I'm having Batch ID and Total Orders and the data format will looks like as given in table below: Batch Table: BatchID TotalOrders 10001 100 10002 90 ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi,

    Thanks for the solution rajendraongole1  offered,and i want to offer some more infotmation for user to refer to.

    hello Anonymous , you can refer to the following sample.

    Sample data 

    Create the following measures.

    _Decreasing =
    VAR a =
        MAXX (
            FILTER ( ALLSELECTED ( 'Table' ), [BatchID] = MAX ( [BatchID] ) - 1 ),
            [TotalOrders]
        )
    VAR b =
        IF ( a <> BLANK (), a - SUM ( 'Table'[TotalOrders] ) )
    VAR c =
        MINX ( ALLSELECTED ( 'Table' ), [BatchID] )
    RETURN
        IF ( b > 0 || MAX ( 'Table'[BatchID] ) = c, 1, 0 )
    
    _Increment =
    VAR a =
        MAXX (
            FILTER ( ALLSELECTED ( 'Table' ), [BatchID] = MAX ( [BatchID] ) - 1 ),
            [TotalOrders]
        )
    VAR b =
        IF ( a <> BLANK (), SUM ( 'Table'[TotalOrders] ) - a )
    VAR c =
        MINX ( ALLSELECTED ( 'Table' ), [BatchID] )
    RETURN
        IF ( b > 0 || MAX ( 'Table'[BatchID] ) = c, 1, 0 )
    
    Decreasing_flag =
    VAR a =
        MAXX (
            FILTER (
                ALLSELECTED ( 'Table' ),
                [BatchID] <= MAX ( 'Table'[BatchID] )
                    && [_Decreasing] = 0
            ),
            [BatchID]
        )
    VAR b =
        IF (
            a = BLANK (),
            MAX ( 'Table'[BatchID] ) - MINX ( ALLSELECTED ( 'Table'[BatchID] ), [BatchID] ) + 1,
            MAX ( 'Table'[BatchID] ) - a + 1
        )
    RETURN
        IF ( b <> 0 && MOD ( b, 7 ) = 0, 1, 0 )
    
    increasing_flag =
    VAR a =
        MAXX (
            FILTER (
                ALLSELECTED ( 'Table' ),
                [BatchID] <= MAX ( 'Table'[BatchID] )
                    && [_Increment] = 0
            ),
            [BatchID]
        )
    VAR b =
        IF (
            a = BLANK (),
            MAX ( 'Table'[BatchID] ) - MINX ( ALLSELECTED ( 'Table'[BatchID] ), [BatchID] ) + 1,
            MAX ( 'Table'[BatchID] ) - a + 1
        )
    RETURN
        IF ( b <> 0 && MOD ( b, 7 ) = 0, 1, 0 )
    
    Color_flag= IF([Decreasing_flag]=1||[increasing_flag]=1,1,0)

    Then create a line chart visual first, and put the related field to the visual. and sort the visual ascending by BarchID, open the marker.

    Then click the viusal, then change it to clustered column visual.

    Then put the color_flag measure to the column color format.

     

     

    Then click the visual , change it to line chart visual again.

    Output

    Best Regards!

    Yolo Zhu

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