Forum Discussion
Distribute the cost based on a ratio
- 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])
) - 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.
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])
)
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.