FILEPROPERTY - SPACEUSED I used SELECT FILEPROPERTY('file_name', 'SpaceUsed'), and it returns NULL, what does it mean?

I am correctly using it in the correct database.

I cannot assume that NULL means empty since:

I tried to create a new database (test2), then query SELECT FILEPROPERTY('test2', 'SpaceUsed'). It already has a value.
The FILEPROPERTY is expecting a file (not a filegroup).
Make sure the the name you pass in parameter is on one of those :

select name from sys.database_files

This query will give you information about the data files of the selected database:

With A as 
(SELECT db_name() as [Database],fg.name as [FilegroupName],  RTRIM(f.name) AS [Segment Name], f.groupid AS [Group Id], f.filename AS [File Name], 
CAST(f.size/128.0 AS DECIMAL(10,2)) AS [Size in MB],CAST(FILEPROPERTY(f.name, 'SpaceUsed')/128.0 AS DECIMAL(10,2)) AS [Space Used],
CAST(size/128.0-(FILEPROPERTY(f.name, 'SpaceUsed')/128.0) AS DECIMAL(10,2)) AS [Available Space],
CAST((CAST(FILEPROPERTY(f.name, 'SpaceUsed')/128.0 AS DECIMAL(10,2))/CAST(f.size/128.0 AS DECIMAL(10,2)))*100 AS DECIMAL(10,2)) AS [Percent Used] 
FROM sysfiles f join sys.filegroups fg on f.groupid=fg.data_space_id ) 
select 1 as [order], * from A union  select 2 as [order], REPLICATE('-',10), REPLICATE('-',10), REPLICATE('-',10), 0, REPLICATE('-',50),0,0,0,0 
union 
select 3 as [order], [Database],[FilegroupName],  '', [Group Id], '', sum([Size in MB]), sum([Space Used]), sum([Available Space]), Cast(sum([Space Used])/sum([Size in MB])*100 AS DECIMAL(10,2)) 
from A 
group by [Database],[FilegroupName], [Group Id] 
ORDER BY [order], [Segment Name]


Thanks