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
dmace
Frequent Visitor

Getting value based off Rank

I have a dataset of candidates that have one row per ReferredByWorker. So a candidate whom 3 people referred has three rows. I needed to consolidate the information into one row which I accomplished by creating a Rank in Power Query and then using the following DAX column to get the ReferredByWorkers 

 

 

ReferredByWorker1 = 
VAR cand = 'ReferralSplitsBase'[Candidate_ID_Workday]
RETURN
MAXX(
    FILTER(
        ALL('ReferralSplitsBase'),
        'ReferralSplitsBase'[Rank] = "1"
        &&
        'ReferralSplitsBase'[Candidate_ID_Workday] = cand
    ),
    IF('ReferralSplitsBase'[ReferredByWorker] <> BLANK(), 'ReferralSplitsBase'[ReferredByWorker], [ReferredByForWD]))

 

 

We wanted to go out as far as four referrals so there are four columns using this logic, but incrementing the Rank each time. This is extremely slow but it worked so I dealt with it, now that the project is settling down I want to refactor this using Power Query. I attempted to use the following logic but received a cyclic reference error. 

 

 

ReferredByWorker1 = 
let
   cand = [Candidate_ID_Workday],
   filterTable = Table.SelectRows(
                   Table.SelectColumns(ReferralSplitsBase, {"Rank", "Candidate_ID_Workday", "ReferredByWorker", "ReferredByForWD"}),
                   each ([Rank] = "1" and [Candidate_ID_Workday] = cand)
                 ),
   maxFiltered = List.Max(Table.Column(filterTable, "ReferredByWorker"))
in
   if maxFiltered <> null then maxFiltered else [ReferredByForWD]

 

 

The reason for the ReferredByForWD column is because this data set is pulling data from two sources which are drastically different formats, so I had to do a good bit of transformation to marry them up. Can anyone provide any insight on how to get this to work?

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

Hi @dmace 

1.You can consider to create a coustom column named 'Custom' directly and input the following code

=List.Max(Table.SelectRows(the last step name(e.g #"Changed Type"),(x)=>x[Rank]=1 and x[Candidate_ID_Workday]=[Candidate_ID_Workday])[ReferredByWorker])

 2.Then add a new custom column named 'Custom1'

=if [Custom] <> null then [Custom] else [ReferredByForWD]

 

Best Regards!

Yolo Zhu

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

1 REPLY 1
v-xinruzhu-msft
Community Support
Community Support

Hi @dmace 

1.You can consider to create a coustom column named 'Custom' directly and input the following code

=List.Max(Table.SelectRows(the last step name(e.g #"Changed Type"),(x)=>x[Rank]=1 and x[Candidate_ID_Workday]=[Candidate_ID_Workday])[ReferredByWorker])

 2.Then add a new custom column named 'Custom1'

=if [Custom] <> null then [Custom] else [ReferredByForWD]

 

Best Regards!

Yolo Zhu

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

 

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
Top Kudoed Authors