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
sjhardy
New Member

Help with multiple counts with two variables

Hi all, I hope you can help.  I have a requirement to create two columns.  One column has a candidateID and the other column is clientreqno.  Both columns are set as text.  I want a column that will give me a count of the no of times a candidate id appears next to a requisition, and then another column that will give me the opposite for different reasons.  I have looked through other solutions on the forum but nothing is giving me the right value.  So as an example for CandidateID I would expect 5133447 to return a value of 2 as there are two distinct clientreqno.  and then I want another column that would give me for example clientreqno of 21000044 would have returned 8

 

sjhardy_0-1652300416420.png

I have this, but its giving me 0 as a value.  Can anyone help troubleshoot the dax:

Count =
VAR _clientno = 'Combined Candidate list'[ClientReqNo]
VAR _count =
COUNTROWS(
FILTER(
ALL('Combined Candidate list'),
_clientno='Combined Candidate list'[CandidateID]
)
)
RETURN
IF(
_count > 0,
_count,
0
)
1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @sjhardy ,

 

Please try:

Distinct No each ID =
CALCULATE (
    DISTINCTCOUNT ( 'Combined Candidate list'[ClientReqNo] ),
    ALLEXCEPT ( 'Combined Candidate list', 'Combined Candidate list'[CandidateID] )
)
Distinct ID each No = 
CALCULATE (
    COUNTROWS ( 'Combined Candidate list' ),
    ALLEXCEPT ( 'Combined Candidate list', 'Combined Candidate list'[ClientReqNo] )
)

Output:

Eyelyn9_0-1652757108604.png

 

Best Regards,
Eyelyn Qin
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

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @sjhardy ,

 

Please try:

Distinct No each ID =
CALCULATE (
    DISTINCTCOUNT ( 'Combined Candidate list'[ClientReqNo] ),
    ALLEXCEPT ( 'Combined Candidate list', 'Combined Candidate list'[CandidateID] )
)
Distinct ID each No = 
CALCULATE (
    COUNTROWS ( 'Combined Candidate list' ),
    ALLEXCEPT ( 'Combined Candidate list', 'Combined Candidate list'[ClientReqNo] )
)

Output:

Eyelyn9_0-1652757108604.png

 

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

Ashish_Mathur
Super User
Super User

Hi,

Write these 2 calculated column formulas

=calculate(distinctcount(Data[ClientReqNo]),filter(Data,Data[CandidateID]=earlier(Data[CandidateID])))

=calculate(countrows(Data),filter(Data,Data[CandidateID]=earlier(Data[CandidateID])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. Avoid posting screenshots of your source data if possible.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

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.