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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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        120

>61        200

>61        300

 

 

Regards,

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@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

View solution in original post

Icey
Community Support
Community Support

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.

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

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.

Anonymous
Not applicable

@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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.