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

Create a count of data filtered a by dynamic date in another table

Hi All

I need help with an issue I am having which is a bit above my expertise to resolve. I have explained the issue below but please let me know if you need any more information. I’d appreciate any help I can get as I just can’t seem to figure it out on my own.

What I am trying to achieve

I have two tables, one with information on when a tenant moved to a property and the other on library cards that have been taken out for a period. What I need to do is to see how many library cards were taken out at the address after the individual tenancy started so that I can compare this against the amount of tenants to see if there is a difference.

What I have done

I have created a unique identifier of the 1st line of the address + the postcode. This unique identifier is what I am using to match the records.

I can count the amount of tenants in the property per the unique ID and the amount of library cards, but some of the library cards are before the tenants start date so are not valid. I have tried to use a measure using the calculate function to count the rows in the tenancy tables with a filter of the firstdate of the tenancy but it does not seem to work. My current attempt is below

 

Count library cards = CALCULATE (

 

    COUNTAX('Library '[Library.registration_date],'Library '[Unique identifier] = 'Housing '[Unique identifier]),

    FIRSTDATE('Housing- Library '[Tenancy Start Date]

))

 

 

My tables (example data)

 

Housing table

Unique identifier Tenancy start date AddressPostcodeName
1 fake road a2 12301/01/20161 fake roada2 123John Smith
1 fake road a2 12301/01/20161 fake roada2 123Jane Smith
1 fake road a2 12301/01/20161 fake roada2 123Frank smith
2 fake road a2 12315/02/20162 fake roada2 123John Doe

 

Library table

Unique identifier Library card registered AddressPostcodeName
1 fake road a2 12305/06/20141 fake roada2 123Frank Spencer
1 fake road a2 12307/02/20161 fake roada2 123Jane Smith
1 fake road a2 12307/02/20161 fake roada2 123Frank smith
2 fake road a2 12315/02/20162 fake roada2 123John Doe
1 fake road a2 12303/05/20161 fake roada2 123Jane Smith

 

What I would like to create

Unique indentifier Count of tenancysCount of library cards post tenancy start date Difference
1 fake road a2 123                                    330

 

Any help would be greatly appreciated

 

Regards

 

Dan

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@Danbarton88

 

In this case, I'd use two calculated tables. Check the tables JoinedTbl and Unique identifier in the attached pbix.

 

Capture.PNG

 

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee

@Danbarton88

 

In this case, I'd use two calculated tables. Check the tables JoinedTbl and Unique identifier in the attached pbix.

 

Capture.PNG

 

That works brilliantly! Didn't even cross my mind to create a calculated table.

 

Thank you so much for your help!

 

Dan

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.