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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ays1977
Frequent Visitor

Distribute cost and add rows?

Hi,

 

New to PowerBI and DAX and hope you can help me with the solution. I have cost my income statment the I want to allocate/distribut to a internal number. For some cost I already have the cost on the correct internal number but for som OH cost I need to distribute the cost. For each month the share of each internal number will varies and I also have 2 different result units. 

 

The figures from the income statment as below:

DateVer.Nr.AccountResult unitInternal numberAmount
2023010234113252Rent1 15000
2023010234113252Income112345300
2023010334126272Insurance1 25000
2023010334126272IT1 3000
2023010334126272Income223456500
2023010334126272Insurance2 20000
2023010334126272Rent2 10000
2023020134126255Rent1 50000

 

I also have a table with the share for each internal number per month and resultunit.

PeriodResult unitInternal numberShare
jan-2311234525%
jan-23145678925%
jan-23132165450%
jan-2322345640%
jan-23298765435%
jan-23298799925%
feb-2311234535%
feb-23145678912%
feb-23132165453%

 

What I need, if it´s possible, is for each row that don´t have an internal number I need to slit the amout according the the share for that month and add rows with the date, account, result unit and internal number so I end up with a table as below. Is this possible to do?

DateVer.Nr.AccountResult unitInternal numberAmount 
2023010234113252Rent11234537500,25 of 15000
2023010234113252Rent145678937500,25 of 15000
2023010234113252Rent132165475000,5 of 15000
2023010234113252Income112345300 
2023010334126272Insurance11234562500,25 of 25000
2023010334126272Insurance145678962500,25 of 25000
2023010334126272Insurance1321654125000,5 of 25000
2023010334126272IT1123457500,25 of 3000
2023010334126272IT14567897500,25 of 3000
2023010334126272IT132165415000,5 of 3000
2023010334126272Income223456500 
2023010334126272Insurance22345680000,4 of 20000
2023010334126272Insurance298765470000,35 of 20000
2023010334126272Insurance298799950000,25 of 20000
2023010334126272Rent22345640000,4 of 10000
2023010334126272Rent298765435000,35 of 10000
2023010334126272Rent298799925000,25 of 10000
2023020134126255Rent112345175000,35 of 50000
2023020134126255Rent145678960000,12 of 50000
2023020134126255Rent1321654265000,53 of 50000

 

Regards

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1676433159986.png

NewTable=
FILTER (
    SELECTCOLUMNS (
        GENERATE (
            IncomeStatement,
            SELECTCOLUMNS (
                FILTER (
                    ShareTable,
                    ShareTable[Period] = FORMAT ( IncomeStatement[Date], "mmm-yy" )
                        && ShareTable[Result unit] = IncomeStatement[Result unit]
                ),
                "Res_U", ShareTable[Result unit],
                "Inter_Num", ShareTable[Internal number],
                "share", ShareTable[Share]
            )
        ),
        "Date", IncomeStatement[Date],
        "Ver.Nr.", IncomeStatement[Ver.Nr.],
        "Account", IncomeStatement[Account],
        "Result Unit", IncomeStatement[Result unit],
        "Internal Number", COALESCE ( IncomeStatement[Internal number], [Inter_Num] ),
        "Amount",
            IF (
                ISBLANK ( IncomeStatement[Internal number] ),
                IncomeStatement[Amount] * [share],
                IF ( IncomeStatement[Internal number] = [Inter_Num], IncomeStatement[Amount] )
            )
    ),
    [Amount]
)

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1676433159986.png

NewTable=
FILTER (
    SELECTCOLUMNS (
        GENERATE (
            IncomeStatement,
            SELECTCOLUMNS (
                FILTER (
                    ShareTable,
                    ShareTable[Period] = FORMAT ( IncomeStatement[Date], "mmm-yy" )
                        && ShareTable[Result unit] = IncomeStatement[Result unit]
                ),
                "Res_U", ShareTable[Result unit],
                "Inter_Num", ShareTable[Internal number],
                "share", ShareTable[Share]
            )
        ),
        "Date", IncomeStatement[Date],
        "Ver.Nr.", IncomeStatement[Ver.Nr.],
        "Account", IncomeStatement[Account],
        "Result Unit", IncomeStatement[Result unit],
        "Internal Number", COALESCE ( IncomeStatement[Internal number], [Inter_Num] ),
        "Amount",
            IF (
                ISBLANK ( IncomeStatement[Internal number] ),
                IncomeStatement[Amount] * [share],
                IF ( IncomeStatement[Internal number] = [Inter_Num], IncomeStatement[Amount] )
            )
    ),
    [Amount]
)

Thank you wdx223_Daniel but when I try i get an error message that says that "DAX Comparisons cannot compare values of type Date with values of type TEXT". Can you please share excelfiles and pbix-file or do you have the solution how I can change this? Regards

you must keep the data types be consistent. Date value can not compare with Text value.

here is the file for your reference.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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