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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Cost Allocation/ Distribution

Hi everyone. I have 2 tables like this:

The cost will be distributed based on the ratio in table Allocation.

After distributed, the cost of MKT and IT will be expected to be 0.

Please help me with PBI. Thank you so much. 

ngocpt1__1-1688031306154.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1688371214104.png

2. Create calculated column.

Flag =
VAR _C4 = [Cost]
VAR _C3 =
    SUMX (
        FILTER (
            ALL ( 'Dept_Tabel' ),
            'Dept_Tabel'[Index]
                = EARLIER ( 'Dept_Tabel'[Index] ) - 1
        ),
        [Cost]
    )
VAR _G3 =
    MAXX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] = EARLIER ( 'Dept_Tabel'[Dept] )
        ),
        [%]
    )
VAR _G4 =
    MINX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] IN SELECTCOLUMNS ( 'Dept_Tabel', "1", [Dept] )
        ),
        [%]
    )
VAR _C5 =
    IF (
        'Dept_Tabel'[Dept] = "Sale",
        SUMX (
            FILTER (
                ALL ( 'Dept_Tabel' ),
                'Dept_Tabel'[Index]
                    = EARLIER ( 'Dept_Tabel'[Index] ) + 1
            ),
            [Cost]
        ),
        SUMX (
            FILTER (
                ALL ( 'Dept_Tabel' ),
                'Dept_Tabel'[Index]
                    = EARLIER ( 'Dept_Tabel'[Index] ) - 1
            ),
            [Cost]
        )
    )
VAR _G5 =
    MINX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] = EARLIER ( 'Dept_Tabel'[Dept] )
        ),
        [%]
    )
VAR _G6 =
    MAXX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] = EARLIER ( 'Dept_Tabel'[Dept] )
        ),
        [%]
    )
RETURN
    IF (
        'Dept_Tabel'[Dept] IN SELECTCOLUMNS ( 'Allocation_Table', "1", [Dept] ),
        0,
        IF (
            [Dept] = "Sale",
            _C4 + _C3 * _G3 + ( _C3 * _G4 + _C5 ) * _G5,
            _C4 + ( _C5 * _G4 + _C5 ) * _G6
        )
    )

3. Result:

vyangliumsft_1-1688371214104.png

 

Best Regards,

Liu Yang

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
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1688371214104.png

2. Create calculated column.

Flag =
VAR _C4 = [Cost]
VAR _C3 =
    SUMX (
        FILTER (
            ALL ( 'Dept_Tabel' ),
            'Dept_Tabel'[Index]
                = EARLIER ( 'Dept_Tabel'[Index] ) - 1
        ),
        [Cost]
    )
VAR _G3 =
    MAXX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] = EARLIER ( 'Dept_Tabel'[Dept] )
        ),
        [%]
    )
VAR _G4 =
    MINX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] IN SELECTCOLUMNS ( 'Dept_Tabel', "1", [Dept] )
        ),
        [%]
    )
VAR _C5 =
    IF (
        'Dept_Tabel'[Dept] = "Sale",
        SUMX (
            FILTER (
                ALL ( 'Dept_Tabel' ),
                'Dept_Tabel'[Index]
                    = EARLIER ( 'Dept_Tabel'[Index] ) + 1
            ),
            [Cost]
        ),
        SUMX (
            FILTER (
                ALL ( 'Dept_Tabel' ),
                'Dept_Tabel'[Index]
                    = EARLIER ( 'Dept_Tabel'[Index] ) - 1
            ),
            [Cost]
        )
    )
VAR _G5 =
    MINX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] = EARLIER ( 'Dept_Tabel'[Dept] )
        ),
        [%]
    )
VAR _G6 =
    MAXX (
        FILTER (
            ALL ( Allocation_Table ),
            'Dept_Tabel'[Dept] = EARLIER ( 'Dept_Tabel'[Dept] )
                && 'Allocation_Table'[Allocate] = EARLIER ( 'Dept_Tabel'[Dept] )
        ),
        [%]
    )
RETURN
    IF (
        'Dept_Tabel'[Dept] IN SELECTCOLUMNS ( 'Allocation_Table', "1", [Dept] ),
        0,
        IF (
            [Dept] = "Sale",
            _C4 + _C3 * _G3 + ( _C3 * _G4 + _C5 ) * _G5,
            _C4 + ( _C5 * _G4 + _C5 ) * _G6
        )
    )

3. Result:

vyangliumsft_1-1688371214104.png

 

Best Regards,

Liu Yang

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

Kishore_KVN
Solution Sage
Solution Sage

Hello @Anonymous , please let us know if they become '0' based on any calculation. If not tell us the logic you are looking into bit clearly. 

Anonymous
Not applicable

Hi @Kishore_KVN  thank you for checking on it.

 

For MKT and IT, just dont mind it because I'll set it fixly as 0.

For the other depts, I've noted down the formula to cal it right next to the result. It will be:

orginal cost  + cost that distributed from IT and MKT.

 

Thank you so much.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.