Forum Discussion

zzzsharepoint's avatar
3 years ago
Solved

Distribute the cost based on a ratio

I have two tables one table say a tenant and the total cost and other table say the tenant and the project and their ratio of occupancy of those projects. How can i calculate the cost of each project...
  • bhelou's avatar
    3 years ago

    To calculate the cost of each project for each tenant based on the ratio of occupancy, you can use the following DAX formula:


    Project Cost =
    VAR TotalCost = SUM('Table A'[Cost])
    RETURN
    CALCULATE(
    TotalCost *
    SUMX(
    FILTER('Table B',
    'Table B'[tenant] = EARLIER('Table C'[Tenant]) &&
    'Table B'[Category] = EARLIER('Table A'[Category])
    ),
    'Table B'[Value]
    ) *
    IF('Table C'[ratio of TS] > 0,
    IF(ISBLANK('Table C'[ratio of NTS]), 'Table C'[ratio of TS], 'Table C'[ratio of TS] / ( 'Table C'[ratio of TS] + 'Table C'[ratio of NTS] )),
    IF(ISBLANK('Table C'[ratio of NTS]), 0, 'Table C'[ratio of NTS] / ( 'Table C'[ratio of TS] + 'Table C'[ratio of NTS] ))
    ),
    'Table A'[Category] = EARLIER('Table B'[Category])
    )

  • zzzsharepoint's avatar
    zzzsharepoint
    3 years ago

    Have you tried it or copied from CHATGPT to gain some points here? above DAX will not work in Power Bi and if you really want to learn please start reading rather than blindly following what chatgpt says.