Forum Discussion
Dax measure help
- 1 year ago
Hi SilentEagle ,
Can you please confirm what you are using Power BI or Excel?
Hi thank you so much! I changed up the formula a bit because I don`t have the region, country columns in the cost table only the entities in one column. This partially works but the issue is I cant see the allocated cost in my power pivot when using the entity column from the mapping table. I can only see it when I use the entity column from the cost table as a filter. Both of the cost and net sales tables have a relationship with the mapping table so I dont understand why I cant see the values (all of the other dynamic measures work with my filters and slicers). If I change the first part of the formula to lookup entity from mapping table the measure doesn`t return any values in the pivot but if I double click on "JPN" as an example I can see there is cost allocated. Am I doing something wrong in mapping the entities?
Allocated cost:=VAR CurrentEntity = MAX('BDG 24 25'[Entity])
VAR IsTargetEntity = CurrentEntity IN {"SGP", "JPN"}
VAR ASC_Cost =
CALCULATE(
[BDG YTD],
'BDG 24 25'[Entity] = "ASC"
)
VAR EntityNetSales =
CALCULATE(
SUM(NetSales[Value]),
NetSales[Scenario] = "BDG",
NetSales[Entity] = CurrentEntity
)
VAR TotalTargetNetSales =
CALCULATE(
SUM(NetSales[Value]),
NetSales[Scenario] = "BDG",
NetSales[Entity] IN {"SGP", "JPN"}
)
VAR AllocationRatio =
DIVIDE(EntityNetSales, TotalTargetNetSales, 0)
VAR AllocatedAmount =
IF(
IsTargetEntity,
ASC_Cost * AllocationRatio,
0
)
RETURN
AllocatedAmount
Hi SilentEagle ,
Thank you for reaching out to us on the Microsoft Fabric Community Forum.
Using related function would be a good way. If the mapping table is on one side you can use the Related function on the entity.
Allocated cost:=
//VAR CurrentEntity = MAX('BDG 24 25'[Entity])
//VAR IsTargetEntity = CurrentEntity IN {"SGP", "JPN"}
VAR ASC_Cost =
CALCULATE(
[BDG YTD],
'BDG 24 25'[Entity] = "ASC"
)
VAR EntityNetSales =
CALCULATE(
SUM(NetSales[Value]),
NetSales[Scenario] = "BDG",
RELATED('BDG 24 25'[Entity]) IN {"SGP", "JPN"}
)
VAR TotalTargetNetSales =
CALCULATE(
SUM(NetSales[Value]),
NetSales[Scenario] = "BDG",
RELATED('BDG 24 25'[Entity]) IN {"SGP", "JPN"}
)
VAR AllocationRatio =
DIVIDE(EntityNetSales, TotalTargetNetSales, 0)
VAR AllocatedAmount =
IF(
IsTargetEntity,
ASC_Cost * AllocationRatio,
0
)
RETURN
AllocatedAmount
If this post was helpful, please give us Kudos and consider marking Accept as solution to assist other members in finding it more easily.