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
Anonymous
Not applicable

[Be Careful! Newbie!] Count Value based on Another Filtered Column

Hi guys, 

I have problems with the calculation of one value. My task is the following:

I have:

table: users with

columns: [id, name, createdAt, partnerId, isPartner]
A user can engage other users, they are the partner. If a user has partnerId, it means they have been engaged by another user. isPartner has values 1 or 0.


I need to count users who have partnerId, but only for partners who were created at a specific date range

 

My measure is here:  

 

 

 

 

allReferals = CALCULATE(
    COUNT(users[id]),
    FILTER(
        'users',
        'users'[partnerId] <> BLANK() 
        && 'users'[partnerId] IN { 
            SELECTCOLUMNS(
                FILTER(
                    'users', 
                    'users'[createdAt] >= CALCULATE(MIN('calendar'[Date]), ALLSELECTED('calendar'[Date]))
                    && 'users'[createdAt] <= CALCULATE(MAX('calendar'[Date]), ALLSELECTED('calendar'[Date]))
                    && 'users'[isPartner] = 1
                ),
            "id2", [id]
            )
        }
    )
)

 

 

 

 

It doesn't work at all. You can see my sample here: allReferals.pbix 

Thanks in advance!

 
 
 
 
 
1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @Anonymous , 

You could try below measure to see whether it work or not.

Measure 1 = CALCULATE(
    COUNT(users[id]),
    FILTER(
        'users',
        'users'[partnerId] <> BLANK() 
        &&'users'[createdAt] >= MIN('calendar'[Date])&& 
                    'users'[createdAt] <= MAX('calendar'[Date])
                    && 'users'[isPartner] = 1
            
    )
)

Best Regards,
Zoe Zhi

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

4 REPLIES 4
dax
Community Support
Community Support

Hi @Anonymous , 

You could try below measure to see whether it work or not.

Measure 1 = CALCULATE(
    COUNT(users[id]),
    FILTER(
        'users',
        'users'[partnerId] <> BLANK() 
        &&'users'[createdAt] >= MIN('calendar'[Date])&& 
                    'users'[createdAt] <= MAX('calendar'[Date])
                    && 'users'[isPartner] = 1
            
    )
)

Best Regards,
Zoe Zhi

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

mhossain
Solution Sage
Solution Sage

Hi @Anonymous 

 

Not sure why you are writing date filter criteria, measure will work already as per your slicer.

Try this

allReferals = CALCULATE(
COUNTROWS(users),users[partnerID]<>BLANK(), users[isPartner]=1)
 
Please let me know if above works
amitchandak
Super User
Super User

@Anonymous , not very clear.

Like

calculate(count(user[ID]),user[isPartner]=1)

Anonymous
Not applicable

calculate(count(user[ID]),user[isPartner]=1)

this will return as the count of users who are partners.

I need users who were engaged by partner-users (they have partnerId != 0) (partner-users should be created from 08/11/2020 to 08/12/2020 for example).

 
 
 
 

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.