Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I have a dataset where Country and Region are both coming into a single column and a lookup table that has both separated into two, along with an allocation %. Is there a way where I can do a sum by Country and add their corresponding allocation amount based on Table B? Table A is joined to Table B on Location = Country.
Table A
Location | Expense |
Mexico | 100 |
USA | 1000 |
North America | 20000 |
South America | 1000 |
Table B
Country | Region | Region % |
USA | North America | 55% |
Mexico | North America | 25% |
Canada | North America | 20% |
In this example, I'm looking to generate a result set that contains the following:
Country | Expense | Allocated | Total Allocation |
USA | 1000 | 11000 | 12000 |
Mexico | 100 | 5000 | 5100 |
My first attempt was the following: Calculate(sum(expense), allexcept(table A)) * sum(region %). This works to an extent, but when I bring in A.Location, the calculation will apply to both the countries and regions, not just the countries.
Thank you for any insight!
Solved! Go to Solution.
Hi @ozne99 ,
Or you also can do like this:
Allocated =
SUMX(
FILTER(
'Table A',
'Table A'[Location] = 'Table B'[Region]
),
'Table A'[Expense] * 'Table B'[Region %]
)
Total Allocation =
VAR x =
SUMX(
FILTER(
'Table A',
'Table A'[Location] = 'Table B'[Country]
),
'Table A'[Expense]
)
RETURN
[Allocated] + x
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ozne99 ,
Or you also can do like this:
Allocated =
SUMX(
FILTER(
'Table A',
'Table A'[Location] = 'Table B'[Region]
),
'Table A'[Expense] * 'Table B'[Region %]
)
Total Allocation =
VAR x =
SUMX(
FILTER(
'Table A',
'Table A'[Location] = 'Table B'[Country]
),
'Table A'[Expense]
)
RETURN
[Allocated] + x
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey @ozne99 ,
You can create a calculated column by the solution which @amitchandak Post.
Else you can create Measure Also,
As table B only seems to have region and country relations. I created new columns in table B.
Allocated = AVERAGEX(FILTER('Table A','Table A'[Location]='Table B'[Region]),'Table A'[Expense]*'Table B'[Region %])
Expense = maxx(FILTER('Table A','Table A'[Location]='Table B'[Country]),'Table A'[Expense])
Link : https://www.dropbox.com/s/gqsbbrwd6vw49fo/allocations_regions.pbix?dl=0
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
120 | |
101 | |
71 | |
61 |