Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Thank you so much
Solved! Go to Solution.
hi @Anonymous - You would need to bring in another table which has distance between possible sales order locations and each warehouse - so in your case each potential location of sales will have 3 records in this "distance" table
You can then rank the distance for each sales order location and then display warehouse for sales order where rank = 1
Rank-Distance =
Please mark the post as a solution and provide a 👍 if my comment helped with solving your issue. Thanks!
Proud to be a Super User!
Hi @Anonymous
If the above posts help, please kindly mark it as a answer to help others find it more quickly. thanks!
If not, please kindly elaborate more.
Hi,
I am confused. What exact result are you expecting? How does one determine the "closest warehouse to a sales order"?
hi @Anonymous - You would need to bring in another table which has distance between possible sales order locations and each warehouse - so in your case each potential location of sales will have 3 records in this "distance" table
You can then rank the distance for each sales order location and then display warehouse for sales order where rank = 1
Rank-Distance =
Please mark the post as a solution and provide a 👍 if my comment helped with solving your issue. Thanks!
Proud to be a Super User!
Hi @Sumanth_23 ,
I am getting an error. I know it something on my side. I am not familer with funtion Power BI. Can you please tell me what I am doing wrong here?
Rank_Distance =
VAR_Rnk =
RANKX(
FILTER(
Main,
Main[Ship_City] = EARLIER(Main[Ship_City])
&& Main[Distance] <> BLANK()
),
Main[Distance],
ASC,
DENSE)
RETURN
IF(Main[Distance] = BLANK(), BLANK(),_Rnk)
Error - The syntax for 'RETURN' is incorrect. (DAX( VAR_Rnk = RANKX( FILTER( Main, Main[Ship_City] = EARLIER(Main[Ship_City]) && Main[Distance] <> BLANK() ), Main[Distance], ASC, DENSE) RETURN IF(Main[Distance] = BLANK(), BLANK(),_Rnk))).
Sample data of my table
Code = Warehouse
Shipcity = Sales Loc
Thank you so much for your help and time!
hi @Anonymous - There were a couple of syntax errors but on fixing them the column is calculating as expected
1. There is SPACE between VAR & _Rnk on line 2
2. There is an additional "," before "ASC,"
Proud to be a Super User!
Hi @Sumanth_23
Thank you I was able to fix the formula, but I think it is not grouping correctly on my one. I see on your picture rank is 1,2,3 for each code (Warehouse) by sales location distance. My one does not show like that.
I am really sorry to bug you, but I think I am really close. Do you know why it that? Please see below, I have selected a few sales orders for your reference.
I even try to swich Ship cit with Code (Warehouse), did not work.
Rank_Distance =
VAR _Rnk =
RANKX(
FILTER(
Main,
Main[Ship_City] = EARLIER(Main[Ship_City])
&& Main[Distance] <> BLANK()
),
Main[Distance],,
ASC,
DENSE)
RETURN
IF(Main[Distance] = BLANK(), BLANK(),_Rnk)
Thank you so much
hi @Anonymous - That is strange - can you check the data types of all columns in your data model. Also I have uploaded the pbix file to the below path - you can take a look and see what is different when compared to your model
https://drive.google.com/file/d/1DiwHnohFxA-dbALMZR0Glkqg_55ifpP_/view?usp=sharing
Please mark the post as a solution and provide a 👍 if my comment helped with solving your issue. Thanks!
Proud to be a Super User!
Hi @Sumanth_23
I am matching data format as it like on your file. I have no idea why it doing like that since I have samething like you. I have uploaded my sample pibix file. I would appreciate you could take look. Thank you so much for the help. There should be something I am missing. Again, million thanks for your help.
https://drive.google.com/file/d/1zQajuEdbPM-RLQYn5Nd8KR-YewFFvHFx/view?usp=sharing
hi @Anonymous - It appears you have data for other values for "Code" which you are filtering out at visual level - since rank is being calculated within your table it is based on the data available.
Please see below if all codes are included then the rank is being evaluated as expected
Please mark the post as a solution and provide a 👍 if my comment helped with solving your issue. Thanks!
Proud to be a Super User!
@Sumanth_23 Thank you so much for your hlpe and time. You are awesome. !! This works for me. I am going to filter it out on my table level. It should work on ranking then. Again, thank you
hi @Anonymous - Happy to help! 🙂
Proud to be a Super User!
Hi,
I do not understand. May be someone else will help you.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.