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
Anonymous
Not applicable

Lookup value function to return value is not blank

Dear all,

 

May I ask your advice on below issue?

 

I want to apply look up value to find a value from a column in Power BI Desktop. However, in the result column have 2 value: blank or # value. So I want that the formula only pickup the # value from result column. Below is example of data. Thanks for your support!

 

Dataset 1

 

ProductSafety time_Plant ASafety time_Plant BSafety time_Plant C
Table5  
Table 4 
Table  3
Chair2  
Chair 1 
Chair  3

 

Dataset 2: => Expected to lookup column safety time from Dataset 1

PlantProductSafety time
ATable5
ATable5
BChair4
CChair3
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Please select all of the column with the prefix "Safety time_Plant" and unpivot these columns in Power Query Editor as suggested by @amitchandak .  

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCklMyklV0lEyBWIQitVBiAGRCRYxIDIGizlnJGYWAXlGSHphYkBkiEUMojcWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"Safety time_Plant A" = _t, #"Safety time_Plant B" = _t, #"Safety time_Plant C" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Safety time_Plant A", Int64.Type}, {"Safety time_Plant B", Int64.Type}, {"Safety time_Plant C", Int64.Type}}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"Safety time_Plant A", "Safety time_Plant B", "Safety time_Plant C"}, "Plant", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Only Selected Columns","Safety time_Plant","",Replacer.ReplaceText,{"Plant"}),
    #"Grouped Rows" = Table.Group(#"Replaced Value", {"Product", "Plant"}, {{"Safety time", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

yingyinr_0-1618386656515.png

But the returned Safety Time is different with yours, could you please provide the calculation logic of Safety Time? How did you get them(5,5,4,3) base on the data from Dataset 1?

yingyinr_1-1618386777669.png

Best Regards

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Please select all of the column with the prefix "Safety time_Plant" and unpivot these columns in Power Query Editor as suggested by @amitchandak .  

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCklMyklV0lEyBWIQitVBiAGRCRYxIDIGizlnJGYWAXlGSHphYkBkiEUMojcWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"Safety time_Plant A" = _t, #"Safety time_Plant B" = _t, #"Safety time_Plant C" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Safety time_Plant A", Int64.Type}, {"Safety time_Plant B", Int64.Type}, {"Safety time_Plant C", Int64.Type}}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"Safety time_Plant A", "Safety time_Plant B", "Safety time_Plant C"}, "Plant", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Only Selected Columns","Safety time_Plant","",Replacer.ReplaceText,{"Plant"}),
    #"Grouped Rows" = Table.Group(#"Replaced Value", {"Product", "Plant"}, {{"Safety time", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

yingyinr_0-1618386656515.png

But the returned Safety Time is different with yours, could you please provide the calculation logic of Safety Time? How did you get them(5,5,4,3) base on the data from Dataset 1?

yingyinr_1-1618386777669.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , if you only have 3 such column

 


New column =
var _A = maxx(filter(Data1,Date1[Product] =Data2[Product]), [Safety time_Plant A])
var _B = maxx(filter(Data1,Date1[Product] =Data2[Product]), [Safety time_Plant B])
var _C = maxx(filter(Data1,Date1[Product] =Data2[Product]), [Safety time_Plant C])

return
Switch([Plant],
"A", _A ,
"B", _B ,
"C", _C
)

 

If need use min in place of Max

 

If there more then 3 such column, Then unpivot the first table

https://radacad.com/pivot-and-unpivot-with-power-bi

And add the filter of plant

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.