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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
stchln
Resolver I
Resolver I

Finding identifier whose given value is smallest

Hello

I need your help for a simple issue I cannot solve... I have a table, named TBL below, that contains columns PR, FA and Prio. I need to create a new column RPR with content equivalent to ExpectedPR column below. It gives for set of PR with same FA the one which has lowest Prio

 

RPR1 below is giving in front of PR the Priority but what I need is PR id whose value is lowest

RPR1 = CALCULATE(
    MIN([Prio]),
    FILTER(TBL,TBL[FA]=EARLIEST([FA]))
)

 

I tried several trials using TOPN, FIRSTNONBLANK, CALCULATE, SUMMARIZE,... but I am not able to find the correct formula. Any idea?

 

stchln_0-1683187957806.png

 

Below just to load the example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjBU0lFycwSRRkAcYKQUqxMNomCihkiixlhFTcCiIB0g+QBTiKgpXNQIKhoLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PR = _t, FA = _t, Prio = _t, ExpectedPR = _t])
in
    Source

 

Thanks for your help!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can use

Calc PR = 
 VAR MinPriority = CALCULATE( MIN( 'Query1'[Prio]), ALLEXCEPT(Query1, Query1[FA]) )
 VAR Result = CALCULATE( MIN( 'Query1'[PR]), ALLEXCEPT(Query1, Query1[FA]), 'Query1'[Prio] = MinPriority)
 RETURN Result

View solution in original post

2 REPLIES 2
stchln
Resolver I
Resolver I

Thanks a lot johnt75, you made my day 😊

johnt75
Super User
Super User

You can use

Calc PR = 
 VAR MinPriority = CALCULATE( MIN( 'Query1'[Prio]), ALLEXCEPT(Query1, Query1[FA]) )
 VAR Result = CALCULATE( MIN( 'Query1'[PR]), ALLEXCEPT(Query1, Query1[FA]), 'Query1'[Prio] = MinPriority)
 RETURN Result

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors