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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tlenzmeier
Helper II
Helper II

New Column based upon other two columns

I am at a bit of a loss on how best to proceed. I need to do a complex calculation based on values from two different tables. I thought I create variables and then do my calculation from there, but I ran into an issue where I could use my SUMX function and join to one table, but not another. 

Here's the scenario:

 

Customer A has three contracts for $500,000 each. They total $1.5 million. At a row-level context, there's a calculation we do based on contract number that is similar to income tax rates. A liability amount is calculated based on a progression. The first $100,000 is excluded, then the next $250,000 is covered at 80% and anything over $350,000 is excluded.  The formula for that is done and working. The twist on all of this is that there is a policy limit of $1 million. We are not liable for anything in excess of that at a customer level. In this example the total liability is capped at $1 million. The customer level context is obviously a step higher than the contract level.

 

My data looks something like this:

 

Customer (table)

CustomerKey (PK), CustomerCode, CustomerName

 

Contract (table)

ContractKey (PK), CustomerKey (FK), ContractNumber, ContractAmount

 

Insurance (table)

PolicyKey (PK), InsuranceType, PolicyYear, MinimumAmount, MaximumAmount, Exposure, AppliedPct

 

I have a one-to-many join from customer to contract. The insurance table is not joined to anything and behaves more like a lookup. We have a compound key (insurance type + policy year) that serves as a join to the contract table.

 

Sample data looks like this:

 

Customer

Customer Key 501

CustomerCode 49113

 

Contract

ContractKey 34

ContractNumber 480, 481, 482,

CustomerKey 501

ContractAmount $500,000, $500,000, $500,000

 

Insurance

CompoundKey: DefIns 17-18

Type: DefIns

ApplicedPct: 1.0

 

CompoundKey: DefIns 17-18,

Type: DefIns,

PolicyYear 17-18,

AppliedPct 0.8

 

CompoundKey: DefIns 17-18,

Type: DefIns,

PolicyYear 17-18,

AppliedPct 0.8

 

I started writing out something like this: Amount = var DefIns = SUMX(FILTER('Insurance', 'Insurance'[CompoundKey] = 'Contract'[CompoundKey] . . .

 

Only half of the join works.

 

Finally, is this a calculation that PowerBI can do? Or should this be done in SQL?

 

Thanks.

 

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@tlenzmeier,

 

It is not very clear, share us a more complete example and the expected output.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.