cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Dynamic calculation for changing Amount

Hi All,

 

How we can create dynamic calculation on changing bucket as :

 

RowBucketStatusBucketAmiount
1<11000
21--2>1000<2000
3>2>2000

   

and in future its change to 

 

RowBucketStatusBucketAmiount
1<22000
22--3>2000<3000
3>3>3000

 

 

I dont want to change the logic which I have created in BI.

 

XYZ = SWITCH(TRUE(),'Table'[Amount]<=BucketAmount_FirstRow,"BucketStatus_FirstRow",'Table'[Amount] is between BucketAmount_SecountRow,"BucketStatus_SecondRow" && 'Table'[Amount]<=BucketAmount_ThirdRow,"BucketStatus_ThirdRow")

 

 

Or in case I have created bucket, Its shd be dynamic.

 

Bucket1 = IF(Data[Amount]<=BucketAmount_FirstRow && YEAR(Data[Date])=(MAX('Date'[Year])),"BucketStatus_FirstRow",
IF(Data[Amount]>=BucketStatus_FirstRow && Data[Amount]< BucketStatus_SecondRow && YEAR(Data[Date])=MAX('Date'[Year]),"BucketStatus_SecondRow",
IF(Data[Amount]>BucketStatus_SecondRow && Data[Amount]<BucketStatus_ThirdRow && YEAR(Data[Date])=MAX('Date'[Year]),"BucketStatus_ThirdRow", BLANK()))))

 

 

Thanks,

R_

1 ACCEPTED SOLUTION
Community Support
Community Support

Hi @R_,

 

Based on your rule table, I write a column to auto generate the bucket state.(For my scenario, you only need to write two row to limit the amount range)

 

Calculate column:

 

Bucket State =
VAR Min_Amount =
    LOOKUPVALUE (
        'Dim Bucket'[BucketAmiount],
        'Dim Bucket'[Row], MINX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
    )
VAR temp =
    LOOKUPVALUE (
        'Dim Bucket'[BucketAmiount],
        'Dim Bucket'[Row], MAXX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
    )
VAR Max_Amount =
    RIGHT ( temp, LEN ( temp ) - 1 )
RETURN
    IF (
        [Amount] <= VALUE ( Min_Amount ),
        LOOKUPVALUE (
            'Dim Bucket'[BucketStatus],
            'Dim Bucket'[Row], MINX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
        ),
        IF (
            [Amount] >= VALUE ( Max_Amount ),
            LOOKUPVALUE (
                'Dim Bucket'[BucketStatus],
                'Dim Bucket'[Row], MAXX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
            ),
            INT ( [Amount] / 1000 )
                & "--"
                & (
                    INT ( [Amount] / 1000 )
                        + 1
                )
        )
    )

 

 10.PNG

 

 

Notice: the min and max status are look from bucket range table, other median parts are auto generated.

11.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

1 REPLY 1
Community Support
Community Support

Hi @R_,

 

Based on your rule table, I write a column to auto generate the bucket state.(For my scenario, you only need to write two row to limit the amount range)

 

Calculate column:

 

Bucket State =
VAR Min_Amount =
    LOOKUPVALUE (
        'Dim Bucket'[BucketAmiount],
        'Dim Bucket'[Row], MINX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
    )
VAR temp =
    LOOKUPVALUE (
        'Dim Bucket'[BucketAmiount],
        'Dim Bucket'[Row], MAXX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
    )
VAR Max_Amount =
    RIGHT ( temp, LEN ( temp ) - 1 )
RETURN
    IF (
        [Amount] <= VALUE ( Min_Amount ),
        LOOKUPVALUE (
            'Dim Bucket'[BucketStatus],
            'Dim Bucket'[Row], MINX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
        ),
        IF (
            [Amount] >= VALUE ( Max_Amount ),
            LOOKUPVALUE (
                'Dim Bucket'[BucketStatus],
                'Dim Bucket'[Row], MAXX ( ALL ( 'Dim Bucket'[Row] ), [Row] )
            ),
            INT ( [Amount] / 1000 )
                & "--"
                & (
                    INT ( [Amount] / 1000 )
                        + 1
                )
        )
    )

 

 10.PNG

 

 

Notice: the min and max status are look from bucket range table, other median parts are auto generated.

11.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

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Microsoft Ignite

Microsoft Ignite with Arun Ulag

Featured Session: Drive Data Culture with Power BI- Vision, Strategy & Roadmap. Register here https://myignite.microsoft.com #MSIgnite #PowerPlatform #Power BI ​

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors