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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
scaballerom
Helper I
Helper I

Filter on RANKX not working

Hi,


I have the following ranking:

RankStartingTimeDeviation =
IF (
    HASONEVALUE('Fact Jobs'[job_name]) && [NumberOfExec]=1,
VAR LookupTable =
    ADDCOLUMNS(ALLSELECTED('Fact Jobs'),"@Deviation",[StartingTimeDeviation])
VAR CurrentValue = CALCULATE([StartingTimeDeviation], 'Fact Jobs'[job_key] = SELECTEDVALUE('Fact Jobs'[job_key]))
VAR Result =
    RANKX (LookupTable, [@Deviation], CurrentValue,DESC,Dense)
RETURN
    Result
    )
where:
StartingTimeDeviation =
VAR StartTime = SELECTEDVALUE('Fact Jobs'[job_starting_time])
Var AvgStartTime = TIMEVALUE([AvgStartingTimeR6M])
VAR Result = IF (AvgStartTime> StartTime, -DATEDIFF(StartTime,AvgStartTime,MINUTE), DATEDIFF(AvgStartTime,StartTime,MINUTE))
RETURN
    Result
and
AvgStartingTimeR6M =
VAR NumberOfDays = 181
VAR MaxDay = MAX('Fact Jobs'[job_starting_datetime])
VAR MinDay = MaxDay-NumberOfDays
VAR FilterContext =
    FILTER (
            ALL('Fact Jobs'),
            'Fact Jobs'[job_status]="Completed" &&
            'Fact Jobs'[job_key] = SELECTEDVALUE('Fact Jobs'[job_key]) &&
            'Fact Jobs'[job_starting_datetime] <= MaxDay && 'Fact Jobs'[job_starting_datetime] > MinDay)
VAR Result =
    CALCULATE(FORMAT(AVERAGE('Fact Jobs'[job_starting_time]),"HH:mm:ss"),FilterContext)
RETURN
    Result
and 
NumberOfExec = CALCULATE(COUNT('Fact Jobs'[job_key]),REMOVEFILTERS('Fact Jobs'[job_starting_time]), KEEPFILTERS('Fact Jobs'[job_starting_date]))
 
The problem I have is that when I try to filter on RankStartingTimeDeviation, all my rows turn blank.

Could someone help me out?
 
Thanks in advance for your help!

BR,
Sara
1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @scaballerom 

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures. I look forward to your response.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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