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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jason_m
Regular Visitor

Date table relationship & dynamic Rankx based on date

Hello,

 

Total noob here. Apologies in advance if I am unable to explain it clearly.

I wanted to show the revenues for the 10 latest trips for each of my destinations.

 

However, I have encountered several problems:

 

1. Date

-When my date slicer shows Mar 1, 2020 - Apr 30, 2020, the table still shows trip numbers outside this range.

("dates[date]" column is on a 1-to-many relationship with "DLR[RETURN date]" column).

 

jason_m_0-1592908702156.png

 

- I tried checking the relationship using the following measure to see if this relationship is working properly, and it was:

return date = SELECTEDVALUE(DLR[RETURN date])

 
 
 
 

snip.PNG

the "return date" measure was working as intended, based on the values in the slicer, however the "RETURN date" column seems to ignore this filter.

 

2. Rankx

I have made 2 measures as trial for ranking the trips based on return dates and destination:

 

measure 1:

trips rank = RANKX(

    FILTER(ALL(DLR),

        DLR[to]="Mombasa" && [return date] <= RELATED(Dates[Date])),

    calculate(

        SELECTEDVALUE(DLR[RETURN date]),

        ALLEXCEPT(DLR,DLR[unique trip number 2],Dates[Date]))

 

measure 2:

trips rank 2 = RANKX(

    FILTER(ALL(DLR),

        DLR[to]="Mombasa"),

    calculate(

        SELECTEDVALUE(DLR[RETURN date]),

        ALLEXCEPT(DLR,DLR[unique trip number 2],DLR[RETURN date]))

    ,,DESC)

 

Measure 1 seems to be completely wrong.

Measure 2 seems to work, but is not dynamic, and still inputs values to filtered our rows (i.e. TO <> "Mombasa"). A visual-level filter can be done here as workaround.

 

Before visual-level filter:

 
snip 2.png
 
after visual-level filter:
snip 3.png
 

if possible I would like to make these ranks dynamic (to reflect 10 latest trips based on the dates selected on the slicer)

 

As a final product, I would like a table with 2 columns:

1. trip number

2. revenue

which is filtered only showing a specific destination, as well as the 10 latest trip numbers based on the date in the slicer.

 

Could someone please help me solve these problems and make me understand the solution?

 

Thanks a lot.

1 REPLY 1
Anonymous
Not applicable

Hi @jason_m ,

 

Could you provide some sample data for testing?Do remember to remove the confidential information.

 

Much appreciated.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.