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

COUNT and USERELATIONSHIP Issue

I would like to count the number of projects with status "Completed" based on an inactive date relationship "Actual Completion Date".

I used the following command:

Completed =
CALCULATE(
COUNTROWS(FILTER('FACT Project','FACT Project'[Status] = "Completed")
),
USERELATIONSHIP('DIM Dates'[Date],'FACT Project'[Actual Completion Date]))+0
It's returning me 0 instead of 14 as a count for the month of May. 
 
omd001_0-1622444291844.png

 

1 ACCEPTED SOLUTION

Hi Denis,

I've managed to fix the issue using a different approach and it worked!

Completed = CALCULATE([Total Projects], 'FACT Project'[Status]="Completed", USERELATIONSHIP('DIM Dates'[Date], 'FACT Project'[Actual Completion Date]))

 I basically created a new measure to count all the projects first, and thereafter filter it with the status then use the inactive relationship.

 

View solution in original post

3 REPLIES 3
selimovd
Super User
Super User

Hey @omd001 ,

 

use the FILTER as an argument for CALCULATE and just count the rows of the basic table. This will be filtered by the arguments in CALCULATE. 

So try the following approach:

Completed =
CALCULATE(
    COUNTROWS( 'FACT Project' ),
    FILTER(
        'FACT Project',
        'FACT Project'[Status] = "Completed"
    ),
    USERELATIONSHIP ( 'DIM Dates'[Date], 'FACT Project'[Actual Completion Date] )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi Denis,

I've managed to fix the issue using a different approach and it worked!

Completed = CALCULATE([Total Projects], 'FACT Project'[Status]="Completed", USERELATIONSHIP('DIM Dates'[Date], 'FACT Project'[Actual Completion Date]))

 I basically created a new measure to count all the projects first, and thereafter filter it with the status then use the inactive relationship.

 

Thanks Denis.

It's strange that it only returned 2 rows of data and I am expecting more. I have no filters causing this so I wonder why it is not returning the expected results.

 

omd001_0-1622507524949.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