Forum Discussion
Replacing a null value with a value fetched from a different row based off a third column
- 2 years ago
Hey cal_hallum
You can achieve this using Power Query in the Power BI Desktop. Try the script bellow.
If this post helps, please mark as solved.
Regards,
Marcel
Script Power Querylet
// Replace the line below with your current data source
Source = YourCurrentTable,// Custom function to look up the corresponding REFERRAL_CONTRACTS_CODE value
CustomFunction = (referralCode) =>
let
correspondingRow = Table.SelectRows(Source, each [REFERRAL_CODE] = referralCode),
result = if Table.IsEmpty(correspondingRow) then null else correspondingRow{0}[REFERRAL_CONTRACTS_CODE]
in
result,// Add a custom column with the desired values
#"Added Custom" = Table.AddColumn(Source, "New_REFERRAL_CONTRACTS_CODE", each CustomFunction([BASE_REFERRAL_CODE]))
in
#"Added Custom"
Hey cal_hallum
You can achieve this using Power Query in the Power BI Desktop. Try the script bellow.
If this post helps, please mark as solved.
Regards,
Marcel
Script Power Query
let
// Replace the line below with your current data source
Source = YourCurrentTable,
// Custom function to look up the corresponding REFERRAL_CONTRACTS_CODE value
CustomFunction = (referralCode) =>
let
correspondingRow = Table.SelectRows(Source, each [REFERRAL_CODE] = referralCode),
result = if Table.IsEmpty(correspondingRow) then null else correspondingRow{0}[REFERRAL_CONTRACTS_CODE]
in
result,
// Add a custom column with the desired values
#"Added Custom" = Table.AddColumn(Source, "New_REFERRAL_CONTRACTS_CODE", each CustomFunction([BASE_REFERRAL_CODE]))
in
#"Added Custom"
- cal_hallum2 years agoRegular Visitor
This has worked great thanks, I've added another step replacing the null values with the New_REFERRAL_CONTRACTS_CODE value to complete this