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 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
- SilentEagle1 year agoRegular Visitor
Hi v-menakakota,
Thanks for your help and apologies for the delay. I tried your suggestion with using "Related" function but I get an error saying that the entity column doesn`t either doesn`t exist or doesn`t have a relationship to any table availabe in the current context. I also tried to use the entity column of the mapping table instead of the cost (BDG) table but I got the same error. Both cost and net sales tables have a relationship on the entity with the entity mapping table so not sure why it doesnt work.
- v-menakakota1 year agoCommunity Support
Hi SilentEagle ,
Can you please provide the details of model view or screenshot it would be easy to figure out.
Thank you.- SilentEagle1 year agoRegular Visitor
Hi v-menakakota ,
Sure, please see below the relationsips and the pivot output. For some reason the % split that is calculated in this sample file through the allocated cost is wrong but in my actual working file it`s correct so you can ignore that. In the 2nd screenshot you can see that with the last shared formula I can only see the allocation if I use the BDG entity column (even though the % is wrong here). If I replace the entity column from BDG table to mapping table in the measure now I can see the allocated cost but it`s not split out, it`s duplicated instead. Also the measure where I tried the previously suggested "related" function is in error.
Many thanks