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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tweidner
Helper I
Helper I

Allocate value to selected categories based on measure

Hi everybody

today I'm trying to achieve the following:

tweidner_0-1679480641887.png

What I'm trying to achieve is to allocate the cost from Plant 'A', based on Days Online, to Plant 'B' and 'C'.

 

Should look like this:

tweidner_1-1679480701109.png

 

Thanks & Rgds
Tobias

3 REPLIES 3
MohammadLoran25
Super User
Super User

Follow these steps to achieve your desired result.

 

1-Create 2 Same Tables which contains your plants. (PlantTable1 and PlanTable2).

PlantTable1 includes Plant1 Column 

PlantTable2 includes Plant2 Column

 

2-Assume your main table name is PlantCost (including Columns Plant, Costs and DaysOnline). Then:

Create relationships between PlantCost and PlantTable1 (on Plant and Plant1)

PlantCost and PlantTable2 (on Plant and Plant2)

 

3-CREATE measures Below:

 

SumOfCosts = SUM(PlantCost[Costs])
-------------------------------------------------
SumOfDaysOnline = SUM(PlantCost[DaysOnline])
-------------------------------------------------
SELECTEDCOST1 =
CALCULATE(
SUMX(ALLSELECTED(PlantTable1),[SumOfCosts]),
CROSSFILTER(PlantTable2[Plant2],PlantCost[Plant],NONE)
)
-----------------------------------------------
SELECTEDDaysOnline2 = CALCULATE(
SUMX(ALLSELECTED(PlantTable2),[SumOfDaysOnline]),
CROSSFILTER(PlantTable1[Plant1],PlantCost[Plant],NONE)
)
-----------------------------------------------------
4-Finally, your AllocatedCost Measure is as below:
 
AllocatedCost =
VAR X=[SELECTEDCOST1]

RETURN
CALCULATE(
 
    DIVIDE(X*[SumOfDaysOnline],[SELECTEDDaysOnline2])
+[SumOfCosts]
,
CROSSFILTER(PlantCost[Plant],PlantTable1[Plant1],NONE)
)
 
For the sample case u used on your post, you need to
select "A" on a slicer for Plant1 from PlantTable1 
AND 
select "B" and "C" on a slicer for Plant2 from PlantTable2.
 
Then by putting Plant2 Column and [AllocatedCost] measure, your result is what you want. 
If this answer solves your problem, please mark it as an accepted solution so the others would find what they need easier.
Regards,
Loran

 

MohammadLoran25
Super User
Super User

Hi @tweidner 

You only have these 3 categories or it is a sample data?

I mean always you want to B and C from A?

Hi @MohammadLoran25 

in my dataset I've like 100 entries in 'Plant' which are allocated to 25 countries.

I didn't mention that because I assume I would be able to solve it, if example scenario is solved.

 

Thanks for your feedback!
Rgds
T

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.