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
MattMcMillin_71
Frequent Visitor

Getting a distinct count of customers, using More than 1 filter in a measure

Hi,
I am trying to develop a measure where I can ascertain the number of customers who have a clients loan taken out ( see DAX below) but bringing in another filter that also says they must have 1 or more other loans with another finance business
Note: The Pay Bracket below is just to allow  other metrics. And the LastNdays, just allows me to use a slicer to select 30/90/180 days which then dynamically changes the measure(s)
If the other measures are called "Non Client" ie Total NonClientLoanLastN days, how could I add this as another level of filtering in the DAX below?
Basically, I want to know the number of customers where TotalClientLoanLastN days >0 and TotalNonClientLoanLastN days >0, so of a number that might have a client loan ( say 100 customers), I can identify how many have both client and non client loan payments.
Below DAX works as it is for the 1st part  ( ie the 100 customers) - is it  a case  of another VAR step?
 
Number of Customers by ClientLoans Bracket Last N =
IF (
    ISFILTERED ( 'Client Loans Bracket'[Bracket]),
    COUNTROWS (
        FILTER (
            VALUES (CategorisedTransactions[customer_id] ),
            VAR PayBracket = CALCULATE( [TotalClientLoanLastN days] *1)
            RETURN
            COUNTROWS (
                FILTER (
                    'Client Loans Bracket',
                    PayBracket >= Client Loans Bracket'[Min] &&
                     PayBracket <= 'Client Loans Bracket'[Max]  ) ) > 0 )),
    DISTINCTCOUNT (CategorisedTransactions[customer_id] ))
 
Thanks in advance for your help
4 REPLIES 4
MattMcMillin_71
Frequent Visitor

TotalClientLoanLastN days =
var TableClientLoanFiltered=
SUMMARIZE('CategorisedTransactions',
CategorisedTransactions[customer_id],
"ClientLoans last N days",
CALCULATE(sumx('Key Measures',[Client Loans]),FILTER('CategorisedTransactions',
       CategorisedTransactions[DATE]<=MAX(CategorisedTransactions[DATE]) &&
        'CategorisedTransactions'[DATE]>MAX(CategorisedTransactions[DATE])-[Total Days])
)    
)
return
SUMX(TableClientLoanFiltered,[ClientLoans last N days])
v-jianboli-msft
Community Support
Community Support

Hi @MattMcMillin_71 ,

 

What does your original data look like?

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

PaydayLoan Bracket =
SWITCH(
       TRUE(),
       [TotalPayLoanLastN days] >= 0.001, "Yes",
            "No"
       )

MattMcMillin_71_0-1692775436819.png

 

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