Forum Discussion

Tezaroyal's avatar
Tezaroyal
Frequent Visitor
3 years ago
Solved

Dax Issue

Hi,   I'm trying to show the total nights between the Arrivaldate and depaturedate based on slicer selection    Below is an example.  The logic behind the Total nights column is the count of nig...
  • rubayatyasmin's avatar
    3 years ago

    HI, Tezaroyal 

     

    You are attempting to create a card visual with this measure, but it is likely returning BLANK because the card visual does not have a row context to reference. This issue arises because a card visual is designed to display single aggregated value (like a sum or an average), and SELECTEDVALUE is not able to work in this context as it returns the value when there's only one value in the specified column for the current filter context, otherwise it returns an alternate result you specify or BLANK() by default.

    You may need to revise your measure to handle a situation when multiple or no rows are selected, possibly by replacing SELECTEDVALUE with MIN or MAX, or other suitable aggregate function that would work for your specific case. This would allow you to calculate the total nights even when more than one row is selected.

    However, a more effective way could be creating a new table that will create a row for each night a guest stayed and then sum up the rows that fall into the selected slicer dates. This could give you a simple count of rows as a result which could be placed in the card visual.

    Remember, without a specific row context, SELECTEDVALUE function will likely not work the way you expect in card visuals.

     

    If my assistance helped you in any way, hit 👍