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
anileshknpowerb
Helper III
Helper III

Bucketing based on SUM

Hello,

 

I have to create a bucketing based on SUM calculation.

 

For Example, 

 

IF(SUM(COLUMN1)<10, "<10", IF(SUM(COLUMN1)>=10 && SUM(COLUMN1)<=50, "10-50")).

 

How to achieve this using DAX.

 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @anileshknpowerb,

Any regular about these formatting operations? If this is a case, you can create a category table with 'index', 'from', 'to', 'desc' fields.

 

Category =
VAR _current =
    CALCULATE (
        SUM ( 'Sample'[Amount] ),
        FILTER ( 'Sample', [Index] = EARLIER ( 'Sample'[Index] ) )
    )
VAR result =
    CALCULATE (
        MAX ( 'Condition'[Desc] ),
        FILTER ( ALLSELECTED ( 'Condition' ), [From] <= _current && [To] > _current )
    )
RETURN
    IF (
        result <> BLANK (),
        result,
        LOOKUPVALUE (
            'Condition'[Desc],
            'Condition'[Index], MAXX ( ALL ( 'Condition'[Index] ), [Index] )
        )
    )

 

6.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @anileshknpowerb,

Any regular about these formatting operations? If this is a case, you can create a category table with 'index', 'from', 'to', 'desc' fields.

 

Category =
VAR _current =
    CALCULATE (
        SUM ( 'Sample'[Amount] ),
        FILTER ( 'Sample', [Index] = EARLIER ( 'Sample'[Index] ) )
    )
VAR result =
    CALCULATE (
        MAX ( 'Condition'[Desc] ),
        FILTER ( ALLSELECTED ( 'Condition' ), [From] <= _current && [To] > _current )
    )
RETURN
    IF (
        result <> BLANK (),
        result,
        LOOKUPVALUE (
            'Condition'[Desc],
            'Condition'[Index], MAXX ( ALL ( 'Condition'[Index] ), [Index] )
        )
    )

 

6.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
harshnathani
Community Champion
Community Champion

Hi @anileshknpowerb ,

 

Create a Calculated Column

 

 

New Column =
SWITCH (
    TRUE (),
    'Table'[Column1] < 10, "<10",
    'Table'[Column1] >= 10
        && 'Table'[Column1] <= 50, "10-50"
)

 

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

I need to  bucket it based on SUM(COLUMN1) , NOT COLUMN1. How to do this?

Hi @anileshknpowerb ,

 

Share sample date and your expected output.

 

Regards,

HN

Sample Data:

 

COLUMN1: 

3

17

17

4

8

9

 

Expected output:

3          "<10"

34        "10-50"

4         "<10"

8        "<10"

9        "<10"

 

 

 

HI @anileshknpowerb ,

 

What is the logic behind aggregating 17 and not other values?

 

Can you share proper sample data and expected output ?

 

Regards,

Harsh Nathani

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.

Top Solution Authors