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
Walter7432
New Member

RANKX with Grouping, A single value for column 'Price' in table 'query' cannot be determined

I have a list of prices from different suppliers. Grouping is done by EAN.
My goal is to create a rank per EAN. Who is the cheapest 1,2,3,4.
 
I tried new measure and new column. Both give the same error.
Ranking column = RANKX(ALLEXCEPT(query,query[EAN Code]),query[Price])
 
Error
A single value for column 'Price' in table 'query' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
 
 
Walter7432_0-1649073636265.png
Walter7432_1-1649075931706.png

 

What am i missing?

Thanks

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Walter7432 ,

According to your description, here's my solution.

Create a calculated column.

Ranking column =
RANKX (
    FILTER ( ALL ( query ), 'query'[EAN Code] = EARLIER ( query[EAN Code] ) ),
    query[Price],
    ,
    ASC
)

Or create a measure.

Ranking Measure =
RANKX (
    FILTER ( ALL ( query ), 'query'[EAN Code] = MAX ( query[EAN Code] ) ),
    CALCULATE ( SUM ( query[Price] ) ),
    ,
    ASC
)

Get the correct result.

vkalyjmsft_0-1650010642239.png

I attach the sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

6 REPLIES 6
v-yanjiang-msft
Community Support
Community Support

Hi @Walter7432 ,

According to your description, here's my solution.

Create a calculated column.

Ranking column =
RANKX (
    FILTER ( ALL ( query ), 'query'[EAN Code] = EARLIER ( query[EAN Code] ) ),
    query[Price],
    ,
    ASC
)

Or create a measure.

Ranking Measure =
RANKX (
    FILTER ( ALL ( query ), 'query'[EAN Code] = MAX ( query[EAN Code] ) ),
    CALCULATE ( SUM ( query[Price] ) ),
    ,
    ASC
)

Get the correct result.

vkalyjmsft_0-1650010642239.png

I attach the sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

PaulDBrown
Community Champion
Community Champion

Use SUM(query[price]) instead of query[price]





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks for the reply. I made the changes to both typs column and measure:

 

  • Ranking column = RANKX(ALLEXCEPT(query,query[EAN Code]),SUM(query[price]))
    If i use a new column, i get the error
    <pi>A circular dependency was detected: Query1[Ranking column].</pi> 

 

  • Ranking Measure = RANKX(ALLEXCEPT(query,query[EAN Code]),SUM(query[price]))
    If i use a measure, another error pops up when i insert it into a visual

Walter7432_0-1649081578604.png

 

 

 

Oh I see...for the measure, try

Rank EAN =
VAR _sum =
    SUM ( query[price] )
RETURN
    RANKX ( ALLSELECTED ( query[EAN Code] ), _sum )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Formula works, but Rank is now same for all. 🙄

 

Data View

Walter7432_5-1649084568112.png

Visual

Walter7432_6-1649084625041.png

 

 

 

 

That's because you included another column in the visual. 

Rank EAN =
VAR _sum =
    SUM ( query[price] )
RETURN
    RANKX ( ALL ( query[EAN Code] , query[Name] ), _sum )




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.