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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
willit6182
Frequent Visitor

Calculated Column: Return String associated w Highest value in a subset group

Hi everyone. I would really appreciate some help with the following issue that I have not been able to figure out after scouring the forums.

 

I have the following 3 tables:

 

Table_Visit

Visit

Procedure Code

RVU Value

1

22

1.3

1

10

4.2

1

55

3.7

2

22

1.3

3

31

5.0

3

40

2.1

4

22

1.3

4

10

4.2

4

76

3.7

4

40

2.1

5

55

3.7

5

31

5.0

6

22

1.3

6

55

3.7

 

Table_ProcedureCode

Procedure Code

Category

10

A

22

A

31

B

40

B

55

C

76

C

 

Table_Category

Category

Sort Order

A

3

B

1

C

2

 

 

I would like to create a calculated column in Table_ID that returns the Category (A, B, or C) which is associated with the Procedure Code that has the highest RVU Value for that Visit#. The result should be the same for all rows with the same Visit#.

 

i.e. the final new column should look like this:

 

Table_Visit

Visit

Procedure Code

RVU

CALCULATED COLUMN

1

22

1.3

A

1

10

4.2

A

1

55

3.7

A

2

22

1.3

A

3

31

5.0

B

3

40

2.1

B

4

22

1.3

A

4

10

4.2

A

4

76

3.7

A

4

40

2.1

A

5

55

3.7

B

5

31

5.0

B

6

22

1.3

C

6

55

3.7

C

 

I need this to be a calculated column rather than a measure so that I can use it as dimensional data within the Legend field on several visual charts. I have the sort table so that I can sort the display of the categories manually.

1 ACCEPTED SOLUTION

ThxAlot_0-1721202151449.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

4 REPLIES 4
ThxAlot
Super User
Super User

Easy enough,

ThxAlot_0-1721163577809.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



This works! But now I need to ignore all individual Category A procedure codes. Just act like they aren't there.

 

In Visit 1, Codes 10 and 22 would be ignored. Procedure Code 55 would now be the highest RVU value and the Visit Category would change from A to C.

 

I have tried the following modification with a one to many relationships btw tables, but somehow it isn't filtering correctly. Instead it's returning the same Category for ALL rows...

 

Any ideas?

 

Category CC =
MAXX(
    CALCULATETABLE(
        TOPN(1, VISIT, VISIT[RVU Value]),
        ALLEXCEPT(VISIT, VISIT[Visit]),
        FILTER( VISIT, RELATED( PROC [Category]) <> "A")
    ),
    RELATED( PROC [Category]]
))

ThxAlot_0-1721202151449.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



rajendraongole1
Super User
Super User

Hi @willit6182 - create a calculated column in Table_Visit that returns the category associated with the Procedure Code having the highest RVU Value for each Visit# as follows

HighestRVUCategory =
VAR CurrentVisit = Table_Visit[Visit]
VAR HighestRVU =
CALCULATE(
MAX(Table_Visit[RVU Value]),
FILTER(
Table_Visit,
Table_Visit[Visit] = CurrentVisit
)
)
VAR HighestRVUProcedureCode =
CALCULATE(
MAX(Table_Visit[Procedure Code]),
FILTER(
Table_Visit,
Table_Visit[Visit] = CurrentVisit &&
Table_Visit[RVU Value] = HighestRVU
)
)
RETURN
CALCULATE(
MAX(Table_ProcedureCode[Category]),
FILTER(
Table_ProcedureCode,
Table_ProcedureCode[Procedure Code] = HighestRVUProcedureCode
)
)

 

rajendraongole1_0-1721151327235.png

 

Check the above Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors