cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
casperlow
Frequent Visitor

RANK and order by ID and Date

Hi Dax Gurus,

 

Needing a little help here.

 

I'm struggling to order this ranking by ID and Date.

Currently my dax is only ordering by ID.
See table below:

casperlow_0-1664263484137.png

 



See query below:

 

CS RankOrder = --Continious shift rank order
VAR CShiftID =
CALCULATETABLE(
    VALUES('Fact Visit'[Continuous Shift ID]),
    ALLSELECTED()
)
VAR CurrentORder =
SELECTEDVALUE('Fact Visit'[Continuous Shift ID])
VAR Result =
    IF(
        HASONEVALUE('Fact Visit'[Continuous Shift ID]),
        RANKX (
            CShiftID,
            'Fact Visit'[Continuous Shift ID],
            CurrentORder,
            ASC
        )
    )
RETURN
Result

Looking for your help here!
many thanks

 

2 REPLIES 2
wdx223_Daniel
Super User
Super User

CS RankOrder = --Continious shift rank order
VAR CShiftID =
CALCULATETABLE(
    SUMMARIZE('Fact Visit','Fact Visit'[Continuous Shift ID],'Fact Visit'[Start Date]),
    ALLSELECTED()
)
VAR CurrentORder =
SELECTEDVALUE('Fact Visit'[Continuous Shift ID])&SELECTEDVALUE('Fact Visit'[Start Date])
VAR Result =
    IF(
        HASONEVALUE('Fact Visit'[Continuous Shift ID]),
        RANKX (
            CShiftID,
            'Fact Visit'[Continuous Shift ID]&'Fact Visit'[Start Date],
            CurrentORder,
            ASC
        )
    )
RETURN
Result

Hi Daniel,
Apologies I might have ask the wrong question. but technically you did answer the question well.
I did a similar dax for this with date but it doesn't group it with the same continuous_shift_id.

Column CS TEST Rank is the dax formula you gave. See image below.

I guess do you have any suggestion on how do I tackle this?
casperlow_0-1664329985544.png

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors