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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jeffgarlisch
Helper I
Helper I

Count Values Based on On Category A, On Category B, or Both Categories,

I have a data set that looks like so 

dc.JPG

 

 

 

Merchant ID column contains repeated values for a specific merchant

Transaction ID contains unique values for each transaction

Credit Debit Column Flags whether the transaction is a Credit or a Debit

 

 

I'm wondering if there is DAX i could use to calculate the Counts pictured above. 

 

Count of Merchant doing ONLY Debit transactions

Count of Merchant doing ONLY Credit transactions

Count of Merchant doing BOTH Debit & Credit transactions

Count of All Merchants

 

 

This is what I have so far, its a hard value to verify manually querying the database, and I have a feeling the formulas are incorrect!

 

Counts Total Merchants:

TotalMerchants = DISTINCTCOUNT(DST_TGO[MID])

Counts Total Debit Merchants:

TotalDebitMerchants = CALCULATE(DISTINCTCOUNT(DST_TGO[MID]),CreditDebitCode[IsDebit] = 1)

Counts Total Credit Merchants

TotalCreditMerchants = 
CALCULATE(DISTINCTCOUNT(DST_TGO[MID]),CreditDebitCode[IsDebit] = 0)

Thanks in advance!

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

Hi@ jeffgarlisch

You need to improve your measure and do them more deeply

Count Combo = [TotalCreditMerchants]+[TotalDebitMerchants]-[TotalMerchants] 
Count Credit = [TotalMerchants]- [TotalDebitMerchants]
Count Debit = [TotalMerchants]- [TotalCreditMerchants]

Result:

4.png

Best Regards,

Lin

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

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

Hi@ jeffgarlisch

You need to improve your measure and do them more deeply

Count Combo = [TotalCreditMerchants]+[TotalDebitMerchants]-[TotalMerchants] 
Count Credit = [TotalMerchants]- [TotalDebitMerchants]
Count Debit = [TotalMerchants]- [TotalCreditMerchants]

Result:

4.png

Best Regards,

Lin

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

Thanks so much! I dont know why I didnt thinkof that, I must've been too close to the problem! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors