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
KrikkitWars42
New Member

Distributing Value into specified category

I have the following dataset and a seperate total amount that varies, let's say at this time it is -150. I need to distribute that -150 to specific categories untill -150 is at 0. For example the -150 will first go to Dog - 30, making Dog - 0, and then we have -120 that will go into Groceries - 400, making groceries 280, and that takes up all of the original -150 so it doesnt need to be distributed further. 

KrikkitWars42_1-1670173076568.png

The way I am currently doing it is causing memory issues, so I am hoping you all know of better way to do it. 

Thanks!

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

Hi @KrikkitWars42 ,

I have created a  simple sample, please refer to it to see if it helps you.

Create measures.

Measure =
VAR _2 =
    IF ( MAX ( 'Table'[Index] ) >= 4, [Budget by categorym], BLANK () )
RETURN
    SUMX (
        FILTER ( ( 'Table' ), 'Table'[Index] >= SELECTEDVALUE ( 'Table'[Index] ) ),
        _2
    )
Measure2 =
VAR _1 = - ( -150 )
VAR _2 =
    SUMX (
        FILTER ( ALL ( 'Table' ), 'Table'[Index] <= SELECTEDVALUE ( 'Table'[Index] ) ),
        [Measure]
    )
VAR _re =
    IF ( _1 <= _2, MAX ( 'Table'[purchase] ), BLANK () )
RETURN
    _re

 

result =
VAR _1 =
    MINX ( FILTER ( ALL ( 'Table' ), [Measure 2] <> BLANK () ), 'Table'[Index] )
RETURN
    IF (
        MAX ( 'Table'[Index] ) <= _1
            && [Measure] <> BLANK (),
        MAX ( 'Table'[purchase] ),
        BLANK ()
    )

vpollymsft_0-1670205548303.png

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

1 REPLY 1
v-rongtiep-msft
Community Support
Community Support

Hi @KrikkitWars42 ,

I have created a  simple sample, please refer to it to see if it helps you.

Create measures.

Measure =
VAR _2 =
    IF ( MAX ( 'Table'[Index] ) >= 4, [Budget by categorym], BLANK () )
RETURN
    SUMX (
        FILTER ( ( 'Table' ), 'Table'[Index] >= SELECTEDVALUE ( 'Table'[Index] ) ),
        _2
    )
Measure2 =
VAR _1 = - ( -150 )
VAR _2 =
    SUMX (
        FILTER ( ALL ( 'Table' ), 'Table'[Index] <= SELECTEDVALUE ( 'Table'[Index] ) ),
        [Measure]
    )
VAR _re =
    IF ( _1 <= _2, MAX ( 'Table'[purchase] ), BLANK () )
RETURN
    _re

 

result =
VAR _1 =
    MINX ( FILTER ( ALL ( 'Table' ), [Measure 2] <> BLANK () ), 'Table'[Index] )
RETURN
    IF (
        MAX ( 'Table'[Index] ) <= _1
            && [Measure] <> BLANK (),
        MAX ( 'Table'[purchase] ),
        BLANK ()
    )

vpollymsft_0-1670205548303.png

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

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.