cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper III

## SUMX a measure with Filter from multiple tables

Hello Community,

I am trying to Dax the below logic:

sum (Taxes.issuetoemployee + Taxes.taxamount (if taxes.taxIndicator = yes)
+ taxes.employeradvancesamount (if taxes.EmployerAdvancesIndicator = Yes and taxes.timeline =1 and taxes.employeractive = yes)
+ Taxes.SPVamount (if taxes.SPVIndicator = Yes)
+ taxes_beneficiary1amount (if taxes_beneficiary1Indicator = Yes)
+ taxes.beneficiary2amount (if taxes_beneficiary2Indicator = Yes)
where (Application.CanadianBankAccount = No and Application.DirectPayment = No and Payment cycle.PaymentGenerated = Yes)

I am stuck on how to connect this logic in one DAX equation. Your help will be appreciated.

1 ACCEPTED SOLUTION
Community Support

Hi @kalkhudary ,

Thanks for your reply and the detailed info. You can update the formula of measure as below:

``````Measure =
CALCULATE (
SUMX (
Taxes,
Taxes[issuetoemployee]
+ IF ( Taxes[taxIndicator] = "yes", Taxes[taxamount], 0 )
+ IF (
&& Taxes[timeline] = 1
&& Taxes[employeractive] = "yes",
0
)
+ IF ( Taxes[SPVIndicator] = "Yes", Taxes[SPVamount], 0 )
+ IF ( Taxes[beneficiary1Indicator] = "Yes", Taxes[beneficiary1amount], 0 )
+ IF ( Taxes[beneficiary2Indicator] = "Yes", Taxes[beneficiary2amount], 0 )
),
Application[DirectPayment] = "No",
'Payment cycle'[PaymentGenerated] = "Yes"
)``````

Best Regards

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

Hi @kalkhudary ,

You can create a measure as below to get it:

``````Measure =
VAR _issueto =
SUM ( 'Taxes'[issuetoemployee] )
VAR _taxamt =
CALCULATE (
SUM ( 'Taxes'[taxamount] ),
FILTER ( 'Taxes', 'Taxes'[taxIndicator] = "Yes" )
)
CALCULATE (
SUM ( 'Taxes'[employeradvancesamount] ),
FILTER (
'Taxes',
&& 'Taxes'[timeline] = 1
&& 'Taxes'[employeractive] = "Yes"
)
)
VAR _spvamt =
CALCULATE (
SUM ( 'Taxes'[SPVamount] ),
FILTER ( 'Taxes', 'Taxes'[SPVIndicator] = "Yes" )
)
VAR _b1amt =
CALCULATE (
SUM ( 'Taxes'[beneficiary1amount] ),
FILTER ( 'Taxes', 'Taxes'[beneficiary1Indicator] = "Yes" )
)
VAR _b2amt =
CALCULATE (
SUM ( 'Taxes'[beneficiary1amount] ),
FILTER ( 'Taxes', 'Taxes'[beneficiary2Indicator] = "Yes" )
)
RETURN
_issueto + _taxamt + _empadamt + _spvamt + _b1amt + _b2amt``````

And for the following conditions, could you please provide more details on it? The 'Application' and 'Payment cycle' are another two tables? Is there any relationship created among these two tables and the table 'Taxes'?

``where (Application.CanadianBankAccount = No and Application.DirectPayment = No and Payment cycle.PaymentGenerated = Yes)``

If the above one still not help you get the expected result, please provide some raw data in your tables 'taxes','Application' and 'Payment cycle' (exclude sensitive data) with Text format and your expected result with backend logic and special examples.It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

@v-yiruan-msft  Thank you. The 1st part is set and looks good. As for the condition that needs to apply on all the above to Sum the Result.

where (Application.CanadianBankAccount = No and Application.DirectPayment = No and Payment batch.PaymentGenerated = Yes)

I have included the below data model I am using. The taxes are included in the payment table which is connected with the application as one-to-one and connected with the payment batch(cycle) as many to one.

Would we inclue it as a VAR where we have an if condition and Sum or a Sum and Filter and how we will include two filter from 2 different tables. I am stuck here now.

Community Support

Hi @kalkhudary ,

Thanks for your reply and the detailed info. You can update the formula of measure as below:

``````Measure =
CALCULATE (
SUMX (
Taxes,
Taxes[issuetoemployee]
+ IF ( Taxes[taxIndicator] = "yes", Taxes[taxamount], 0 )
+ IF (
&& Taxes[timeline] = 1
&& Taxes[employeractive] = "yes",
0
)
+ IF ( Taxes[SPVIndicator] = "Yes", Taxes[SPVamount], 0 )
+ IF ( Taxes[beneficiary1Indicator] = "Yes", Taxes[beneficiary1amount], 0 )
+ IF ( Taxes[beneficiary2Indicator] = "Yes", Taxes[beneficiary2amount], 0 )
),
Application[DirectPayment] = "No",
'Payment cycle'[PaymentGenerated] = "Yes"
)``````

Best Regards

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

@v-yiruan-msft Thanks alot I believe that solves it. QQ: If I want to sum (Taxes.issuetoemployee + Taxes.taxamount ) Under the condition( taxes.taxIndicator = yes) instead of the below logic. How would I flip it to say Caluclate(SumX( Taxes, Taxes[issuet to employee] +[Taxes.taxamount], if(Taxes[Tax Indictor]="Yes", 0)

This section only

```CALCULATE (
SUMX (
Taxes,
Taxes[issuetoemployee]
+ IF ( Taxes[taxIndicator] = "yes", Taxes[taxamount], 0 )```

Announcements

#### Power BI Monthly Update - November 2023

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

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors