Forum Discussion

jtpiazzamn's avatar
jtpiazzamn
Helper I
3 years ago
Solved

Measure not returning a value

I have a measure using SWITCH but its not returning a value. So I simplified it and its still not working. The strange thing is I have the same measure on a different PowerBI file and it works fine. 
 
Whats wrong with the following measure - its not returning any value for DimValue1 ?
 
Net Value1 =
VAR DimName1 = SELECTEDVALUE('Suggestion Rating'[Suggestion Rating.ratingDimension.name])
VAR DimValue1 = SELECTEDVALUE('Suggestion Rating'[Suggestion Rating.value])
RETURN
DimValue1
 
Thanks in advance. 
Jim
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi jtpiazzamn ,

     

    I made an example for your reference.

    As you can see, the SELECTEDVALUE function returns blank. Because the SELECTEDVALUE function returns the value when the context for columnName has been filtered down to one distinct value only.

    If you select an ID in the slicer, the measure in the card visual returns value. 

    If the slicer doesn't select it, you put the measure into a visual with context, and the measure returns value.

     

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

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

     

2 Replies

  • Hi jtpiazzamn,

     

    Your variable "DimValue1" is using a tricky function - SELECTEDVALUE(). In case multiple values are provided, its result is Blank() (you can learn more about it here - SELECTEDVALUE – DAX Guide).

     

    The first thing I suggest is to test an alternative result and make sure that it's not a case that on a visual, where you use Net Value1, for some row SELECTEDVALUE() of DimValue1 is returning this alternative result.

     

    If not, some more details on 'Suggestion Rating' table, [Suggestion Rating.value] column and the visual where you use Net Value1 might be required.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jtpiazzamn ,

     

    I made an example for your reference.

    As you can see, the SELECTEDVALUE function returns blank. Because the SELECTEDVALUE function returns the value when the context for columnName has been filtered down to one distinct value only.

    If you select an ID in the slicer, the measure in the card visual returns value. 

    If the slicer doesn't select it, you put the measure into a visual with context, and the measure returns value.

     

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

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