Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
kroman
Helper II
Helper II

Custom column that counts rows from other table

Hi All

I have 2 tables: AllFiles (Url (unique) )  and  FilesAccessed (Url, AccessDate)
I need to add custom column to AllFiles that would show how many times particular file was accessed. So something like "NewColumn = CountRows(Filter( FilesAccessed WHERE FilesAccessed[Url] = this row AllFiles[Url] ) 

But just cannot figure out how to do it. 

Thanks

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi @kroman 

You can create a new calculated column for AllFiles and calculate the number of URLs that coincide with FilesAccessed. See if you can solve your problem.

Column =
CALCULATE (
    DISTINCTCOUNT ( FilesAccessed[URL] ),
    FILTER ( 'FilesAccessed', 'FilesAccessed'[URL] = EARLIER ( 'All Files'[URL] ) )
)

vzhangti_0-1634261613794.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

Best Regards

Community Support Team _Charlottez  Zhang
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

8 REPLIES 8
v-zhangti
Community Support
Community Support

Hi @kroman 

You can create a new calculated column for AllFiles and calculate the number of URLs that coincide with FilesAccessed. See if you can solve your problem.

Column =
CALCULATE (
    DISTINCTCOUNT ( FilesAccessed[URL] ),
    FILTER ( 'FilesAccessed', 'FilesAccessed'[URL] = EARLIER ( 'All Files'[URL] ) )
)

vzhangti_0-1634261613794.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

Best Regards

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

 

kroman
Helper II
Helper II

Done it via "Modeling" > "New Column" but getting blank fileds, although there is some values in Search
MHS_PBI1.PNG

@kroman 

 

Have you checked those Url that have blank? is there any value in FilesAccessed table for those Url?

 

Try this if there is Url for them:

NewColumn =
CALCULATE (
    COUNTROWS ( FilesAccessed ),
    FILTER ( all(FilesAccessed) , FilesAccessed [Url] = AllFiles[Url] )
)

 

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

Appreciate your Kudos!!

 

Tried it - same result 😕 
Checked values in Url columns in both tables - values are there 

Try this then:

 

New Column =
COUNTROWS (
    FILTER ( ALL ( FilesAccessed ), FilesAccessed[Url] = EARLIER ( AllFiles[Url] ) )
)

 

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

Appreciate your Kudos!!

 

Still the same 😕
MHS_PBI2.PNG

VahidDM
Super User
Super User

Hi @kroman 

 

try this code to add a new column:

 

 

 

NewColumn =
CALCULATE (
    COUNTROWS ( FilesAccessed ),
    FILTER ( FilesAccessed , FilesAccessed [Url] = EARLIER ( AllFiles[Url] ) )
)

 

 




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

Appreciate your Kudos!!

 

Getting "The name 'CALCULATE' wasn't recognized. Make sure it's spelled correctly."

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors