Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Bucket wise sales

Hi  Sales 100 50 20 30 120 200 300   Above sales data i want to convert bucket wise sales:   Bucket   Sales   0-30        20 0-30        30 31-60      50 >61        100 >61        1...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Anonymous 

     

    Create a separate table (Bucket) as below.

     

    Sales BucketLower Upper
    0-30030
    31-603160
    >=6161 

     

    Then create this calculated column in your table. 

     

    Bucket = 
    VAR X = Sales[Amount]
    VAR Filtered =
        FILTER (
            'Bucket',
            VAR Y = 'Bucket'[Upper] RETURN 'Bucket'[Lower] <= X
                && IF ( ISBLANK ( y ), TRUE (), Y >= X )
        )
    RETURN
        MAXX ( Filtered, Bucket[Sales Bucket] )

     

     

    Appreciate with kudos.

    Please mark as solution if this resolves your problem.

     

    Thanks

  • Icey's avatar
    6 years ago

    Hi Anonymous ,

     

    If "Sales" is a column, then you can add a calculated column in your table like so:

    Bucket =
    SWITCH (
        TRUE (),
        [Sales] >= 0
            && [Sales] <= 30, "0-30",
        [Sales] >= 31
            && [Sales] <= 60, "31-60",
        [Sales] >= 61, ">61"
    )
    

    Or, create a measure:

    Bucket =
    SWITCH (
        TRUE (),
        SUM ( 'Table'[Sales] ) >= 0
            && [Sales] <= 30, "0-30",
        SUM ( 'Table'[Sales] ) >= 31
            && [Sales] <= 60, "31-60",
        SUM ( 'Table'[Sales] ) >= 61, ">61"
    )
    

     

    If "Sales" is a measure, then create a measure like so:

    Bucket =
    SWITCH (
        TRUE (),
        [Sales] >= 0
            && [Sales] <= 30, "0-30",
        [Sales] >= 31
            && [Sales] <= 60, "31-60",
        [Sales] >= 61, ">61"
    )
    

     

    Best Regards,

    Icey

     

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