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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mtomova
Helper III
Helper III

Window function DAX, how to partition by if the duplicates are removed in the "Relation" parameter?

Hi,

I am really struggling with WINDOW function in DAX. Clearly I do not fully understand how it works, if I am getting this result.

I am trying to create a rank column, by dividing the data set per "groups". I know it can be done with RANKX, but when I discovered WINDOW function I though "Oh, I can just give it a go, to test my udnerstanding of it.", which  clearly failed...

In my dataset, I have a reference numbers, and each of there references have been placed "on hold", sometimes more than once.

I am trying to create a rank column, which when there is more than one on hold instance, is going to count the reference based on the On hold Start Date.

I am trying to create the "RANK COLUMN", by using RANKX + WINDOW function. 

ReferenceStart DateEnd DateRANK COLUMN
10096307/02/202210/05/20221
10096320/07/202217/08/20222
10096325/07/202227/07/20223
10096425/07/202227/07/20221
10096527/01/202303/03/20233
10096509/06/202220/01/20231
10096525/07/202227/07/20222

 

What I have so far:

RANKX TEST = 

RANKX(

    WINDOW(1, ABS, 1, ABS,

    ,

    ORDERBY('Ref on hold -Copy'[Start Date], ASC),,

    PARTITIONBY('Ref on hold -Copy'[Reference])),

    'Ref on hold -Copy'[Reference],,ASC,Dense)

 

This calculated column returns:

ReferenceStart DateEnd DateRANK COLUMN
10096307/02/202210/05/20221
10096320/07/202217/08/20221
10096325/07/202227/07/20221
10096425/07/202227/07/20221
10096527/01/202303/03/20231
10096509/06/202220/01/20231
10096525/07/202227/07/20221

 

I know I have ommitted the "Relation" parameter, but whatever I have tried in there I get this error:
"WINDOW's Relation parameter may have duplicate rows. This is not allowed."

I have tried fixing it witl  ALL('Table name')), or ALLSELECTED(), or other table funcitons, but getting the same error.

I tried DISTINCT(ALL('table Name'), but then got a circular dependacy error.

 

Surely, I am doing something wrong. To create a row count/rank, you need to partition by your dataset and order by a column, but I just got in a relm of error messages.

 

PLEASE HELP!
Thank you!

2 REPLIES 2
AlexisOlson
Super User
Super User

I know this is old but I ran into this yesterday and resolved it using the MATCHBY argument.

 

See this article for more details on MATCHBY:
https://pbidax.wordpress.com/2023/05/25/introducing-matchby-for-dax-window-functions/

Padycosmos
Solution Sage
Solution Sage

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.