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

Dates and relationships

Hi,

I want to count the number of assignments id's based on start date and end date.

 

My table is like this:

bilde.png

 

Relationships:

bilde.png

 

Measures:

Assignments Added by StartDate = CALCULATE(DISTINCTCOUNT(Assignments[AssignmentId]); USERELATIONSHIP(Dates[Date]; Assignments[StartDate]))
Assignments by EndDate = CALCULATE(DISTINCTCOUNT(Assignments[AssignmentId]); USERELATIONSHIP(Dates[Date]; Assignments[EndDate]))
But I get the same result on both measures? What am I missing?
1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Your measures are currently calculating the total number of assignments that has a specific startdate/enddate. If you place them both in cards without applying any filters, they will give you the exact same value as every assignment you have will include both start and enddate. 


Connect on LinkedIn

View solution in original post

16 REPLIES 16
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

If you put your measures in card visual and you did not filter them. Then the results should be same. You can try to put the two measures in table visual toget with then EngagementType column, then you will get excepted result.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

hi @v-frfei-msft 

Ok, but this is a dashboard and I sort of need to use the visual card. I use two different measures and two differet cards, so it should work?

The thing I'm wondering about is how to ask for start and end date, cause I get the same result on both.

 

 


@v-frfei-msft wrote:

Hi @Anonymous ,

 

If you put your measures in card visual and you did not filter them. Then the results should be same. You can try to put the two measures in table visual toget with then EngagementType column, then you will get excepted result.

 


 

tex628
Community Champion
Community Champion

Your measures are currently calculating the total number of assignments that has a specific startdate/enddate. If you place them both in cards without applying any filters, they will give you the exact same value as every assignment you have will include both start and enddate. 


Connect on LinkedIn
Anonymous
Not applicable

Thanks @tex628 , now I understood 🙂

 

Do you also know how I can count assignmentsid and filter on  startdate is greater less than today and end date is greater than today?

tex628
Community Champion
Community Champion

Do i understand you correctly that you want to count the total number of assignments that are currently active? (Started but not ended)


Connect on LinkedIn
Anonymous
Not applicable

@tex628 Yes 🙂

I was thinking this should work, but it gave me me 113, and it should have been over 200

 

candicates on assignments = CALCULATE(DISTINCTCOUNT(Assignments[CandidateId]); FILTER(Assignments; Assignments[StartDate]<TODAY()&& Assignments[EndDate]>TODAY()))

Or this one returns 113 as well:

candicates on assignments = CALCULATE(DISTINCTCOUNT(Assignments[CandidateId]);Assignments[StartDate] < TODAY(); Assignments[EndDate] > TODAY())
tex628
Community Champion
Community Champion

Those measures look like they should work ... 

Create a normal table, assignment , startdate & enddate then add the measure at the end. You should be able to tell which assignments are included as they should get a "1". 

Find a row that should have a "1" but hasn't and we'll go from there and figure out what's wrong!

/ J


Connect on LinkedIn
Anonymous
Not applicable

Hi,@tex628 

I made the table and found some that should have been one:

bilde.png

I'm suspecting that I need to use "userelationship" to get this to work, and I've been experimenting a bit with it, but haven't figured it out yet. I also tried to replace candidateid with assignment which gave me a bit higher number, but not correct yet.

tex628
Community Champion
Community Champion

I used this measure:

AssignmentIDbetween = CALCULATE(DISTINCTCOUNT(Assignments[AssignmentId]),ALL(Dates),Assignments[StartDate]<TODAY(), Assignments[EndDate]>TODAY())

Im getting 422 assignments in total and 225 assignments when you have the filter on Stavanger. 

Could this be correct or is there still something off?


Connect on LinkedIn
Anonymous
Not applicable

hi @tex628 

Correct! I actually just found out myself. It was the slicer on year that was fooling me, and I had to ignore it by using the All(dates)! Thanks a lot!

tex628
Community Champion
Community Champion

No worries! Happy to help 🙂


Connect on LinkedIn
Anonymous
Not applicable

eeh, it's me again @tex628.

I just finalized everything and updated the data, seems like I'm of by 3.  I checked in my data and there I have 228

 

image.png

 

So I tried to debug a bit more by making a table, and I included "date" there. And there I find some blank entries on the date. Can that be the issue? How do I pick them up? Look at the top one here:

image.png

 

Anonymous
Not applicable

Ah nevermind. 

I adjusted the calculation to this and it worked 🙂

 

AssignmentID_all = CALCULATE(DISTINCTCOUNT(Assignments[AssignmentId]);Assignments[StartDate]<=TODAY(); Assignments[EndDate]>=TODAY();ALL(Dates[year]))
tex628
Community Champion
Community Champion

If you can, send me a pbix copy in a PM. I can't really figure it out without getting the whole picture

 


Connect on LinkedIn
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

Can you share a pbix sample file?

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski



 

Anonymous
Not applicable

Hi @Mariusz ,

Sorry for my late reply. Can I share it as a private message?

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.