Forum Discussion
HASONEVALUE help
- 7 years ago
Use FIRSTNONBLANK instead of VALUES.
Cup_h_prmry = if(HASONEVALUE(njrew_h_prmry_outcm[CUPCATNO]),FIRSTNONBLANK(njrew_h_prmry_outcm[CUPDETAILS]),"")
VALUES returns a column of values, which can't be displayed as a single data point. Using FIRSTNONBLANK gets the first value, depending on the current order of the data.
If you're expecting all of the CUPDETAILS values to be the same within the same CUPCATNO, I would use SELECTEDVALUE instead. This way it doesn't just pick a value randomly based on whatever ordering currently happens to be in place.
Cup_h_prmry = SELECTEDVALUE(njrew_h_prmry_outcm[CUPDETAILS], BLANK())
You can also use MAX, MIN, or any other aggregation function to determine which value to pick out of the list.
Hi
i am getting an error on the firstnonblank formula??
Cup_h_prmry = if(HASONEVALUE(njrew_h_prmry_outcm[CUPCATNO]),FIRSTNONBLANK(njrew_h_prmry_outcm[CUPDETAILS]),"")
Ah, my apologies. This is what I get for just writing in the forum and not testing it in PBI. I forgot an argument for FIRSTNONBLANK.
FIRSTNONBLANK(njrew_h_prmry_outcm[CUPDETAILS], 1)
I'm using 1 here as an always true option so that the function returns the first value it gets no matter what. You could replace it with some expression that evaluates to a value when good and a blank when bad to be even more selective about which first value you choose.