Forum Discussion
Need Dax for below logic
Hi All,
I have Two tables Invoice and policy thse two are connected with polid
By using these two tables i need to calculate
1. Revenue
2. Emp fee
3. Broker Fee
Invoice table
| PolId | InvNo | Commission amount | Commission Person | Premium | PolNo | Person Type |
| Pol1 | 2796320 | 1700 | Agency | 10000 | 36182363 | R |
| Pol1 | 2796320 | 340 | Executive | 10000 | 36182363 | P |
| Pol1 | 2796320 | 0 | Representative | 10000 | 36182363 | A |
| Pol2 | 2796322 | 4000 | Agency | 20000 | 52280590302 | R |
| Pol2 | 2796322 | 800 | Executive | 20000 | 52280590302 | P |
| Pol2 | 2796322 | 0 | Representative | 20000 | 52280590302 | A |
| Pol1 | 2796319 | 579.87 | Agency | 3411 | 36182363 | R |
| Pol1 | 2796319 | 115.97 | Executive | 3411 | 36182363 | P |
| Pol1 | 2796319 | 0 | Representative | 3411 | 36182363 | A |
| Pol1 | 2796319 | 0 | Agency | 50 | 36182363 | R |
| Pol1 | 2796319 | 0 | Executive | 50 | 36182363 | P |
| Pol1 | 2796319 | 0 | Representative | 50 | 36182363 | A |
| Pol1 | 2796319 | 0 | Agency | 150 | 36182363 | R |
| Pol1 | 2796319 | 0 | Executive | 150 | 36182363 | P |
| Pol1 | 2796319 | 0 | Representative | 150 | 36182363 | R |
| Pol2 | 2796323 | 1000 | Agency | 5000 | 52280590302 | P |
| Pol2 | 2796323 | 200 | Executive | 5000 | 52280590302 | R |
| Pol2 | 2796323 | 0 | Representative | 5000 | 52280590302 | P |
Policy Table
| PolId | PolPId | EmployeeName | Employee Type | Employee Role |
| Pol2 | 2C08E8EB95E2479E | Isaac Matthews | Executive | Exec Primary |
| Pol2 | 84912CCC640541FB | Lisa Flaugher | Representative | Rep Primary |
| Pol1 | DD3AED0660774D1 | Isaac Matthews | Executive | Exec Primary |
| Pol1 | FAC884C9F9D94CFA | Lisa Flaugher | Representative | Rep Primary |
Result
| PolNo | InvNo | Revenue | Emp_Fee | Broker Fee | Gross | Employee Role |
| 36182363 | 2796320 | 1700 | 340 | 0 | 1360 | Exec Primary |
| 36182363 | 2796320 | 1700 | 0 | 0 | 1700 | Rep Primary |
| 36182363 | 2796319 | 579.87 | 115.97 | 0 | 463.9 | Exec Primary |
| 36182363 | 2796319 | 579.87 | 0 | 0 | 579.87 | Rep Primary |
| 52280590302 | 2796322 | 4000 | 800 | 0 | 3200 | Exec Primary |
| 52280590302 | 2796322 | 4000 | 0 | 0 | 4000 | Rep Primary |
| 52280590302 | 2796323 | 1000 | 200 | 0 | 800 | Exec Primary |
| 52280590302 | 2796323 | 1000 | 0 | 0 | 1000 | Rep Primary |
Revenue logic - what ever the commission is showing for commission person "Agency" that should dispaly for commission person "Employee' and "Representative"
Emp Fee is Pull commission paid to each employee role associated to the invoice
Broker Fee is Pull commission paid to any broker associated to the invoice or commission amount of Person Type "B"
Gross: Revenue - emp fee-Broker Fee
Thanks in advance.
See if this works:
Attached is the sample PBIX file
4 Replies
- PaulDBrown
Community Champion
Can you please explain each of the calculations you need?
- AnonymousNot applicable
Broker fee is Commission Amount paid to the person type "B"
In the given input we don't have person type"B" so that why broker fee showing zero in the out put. but in real i have person type "B"
Gross is subtract Revenue,Emp Fee and Broker Fee
- PaulDBrown
Community Champion
- ERD
Community Champion
Anonymous ,
One of the ways to achieve this result is using the next measures:
Commission_amount = SUM ( 'T1-Invoice'[Commission amount] )Revenue = VAR polNo = SELECTEDVALUE ( 'T1-Invoice'[PolNo] ) VAR invNo = SELECTEDVALUE ( 'T1-Invoice'[InvNo] ) RETURN CALCULATE ( [Commission_amount], 'T1-Invoice'[PolNo] = polNo, 'T1-Invoice'[InvNo] = invNo, 'T1-Invoice'[Commission Person] = "Agency", ALL ( 'T1-EmpType'[Employee Role] ) )Emp_fee = VAR polNo = SELECTEDVALUE ( 'T1-Invoice'[PolNo] ) VAR invNo = SELECTEDVALUE ( 'T1-Invoice'[InvNo] ) RETURN CALCULATE ( [Commission_amount], 'T1-Invoice'[PolNo] = polNo, 'T1-Invoice'[InvNo] = invNo, 'T1-Invoice'[Commission Person] <> "Agency" )Broker Fee = VAR polNo = SELECTEDVALUE ( 'T1-Invoice'[PolNo] ) VAR invNo = SELECTEDVALUE ( 'T1-Invoice'[InvNo] ) VAR empRole = SELECTEDVALUE ( 'T1-EmpType'[Employee Type] ) RETURN CALCULATE ( [Commission_amount], 'T1-Invoice'[PolNo] = polNo, 'T1-Invoice'[InvNo] = invNo, 'T1-EmpType'[Employee Type] = empRole, 'T1-Invoice'[ Person Type] = "B" )Gross = [Revenue] - [Emp_fee] - [Broker Fee]If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.