Forum Discussion

totamum's avatar
totamum
Icon for Helper I rankHelper I
1 year ago

Only display results when filter is selected

I have a card which shows page views for each user and another card which shows whether the page views are above or below average.  I only want this card (Above/Below Average) to display when a user is selected.  The default is when no user is selected, the total sum of page views displays and then it says Above Average, the issue with that is that the sum of page views is always going to be larger than the average so therefore it will always show Above Average. Is there any way to have cards only display when a value is selected?

 

8 Replies

  • Hi totamum ,

    try this:

    Show Above/Below Average =
    IF (
    ISFILTERED ( Users[User] ), -- Checks if a user is selected
    [Above Below Average Measure], -- Displays your existing measure when a user is selected
    BLANK() -- Returns blank when no user is selected
    )

     

    Please mark this as solution if it helps you. Appreciate Kudos.

    • totamum's avatar
      totamum
      Icon for Helper I rankHelper I

      It says Blank and doesn't change when a user is selected 

       

  • Solution 1: DAX for Visibility Management

    To limit the card being shown, you will need to create a measure that returns a value only when a user is selected, otherwise a blank value is returned.

    Step 1: To Create a Measure

    DAX

    Edit Copy
    AboveBelowAverage =

    VAR SelectedUser = SELECTEDVALUE(‘Users’[User])

    VAR UserPageViews = SUM(‘PageViews’[Views])

    VAR AvgPageViews = AVERAGE(‘PageViews’[Views])

    RETURN

    IF(

    ISBLANK(SelectedUser),

    BLANK(), – Hide when no user is selected

    IF(UserPageViews > AvgPageViews, “Above Average”, “Below Average”)

    )

    Step 2: Make This Card Measure Active

    Using Power Bi Card visual’s field function, take out the current field and replace it with this measure.

    Above/Below Average card, will usually not display when no user is selected as Power BI card visuals automatically hide blank values.

    Solution 2: Apply a Visual Level Filter
    Another option is applying a visual level filter to the card.

    Click the Above/Below Average card.

    Go to Filters pane and on filter type select ‘Users’[User] field.

    Filter to is not blank.

    This ensures that the card only shows up when a user is selected.

    • totamum's avatar
      totamum
      Icon for Helper I rankHelper I

      Thank you, solution 1 worked except it actually says Blank and I'd rather it not have anything, how can it literally be blank?

       

      Once user is selected

       

  • Hi totamum ,
    If you need to ensure that exactly one user is selected, you can use HASONEVALUE function:

    AboveBelowAvg =
    IF(
        HASONEVALUE(Users[UserID]),  // Check if exactly one user is selected
        [Your measure used to calculate bellow and above],
        BLANK()
    )
    

     

    Or you can check if the UserID column is being filtered ( with one or multiple user's):

    AboveBelowAvg =
    IF(
        ISFILTERED(Users[UserID]),  // Check if there's any filter on the UserID column
        [Your measure used to calculate bellow and above],
        BLANK()   // Return blank when no filter is applied (i.e. no user is selected)
    )
    
    • totamum's avatar
      totamum
      Icon for Helper I rankHelper I

      Thanks no I'd just like to not have a value display when nothing is selected.  I tried the second one but it says Blank even when users are selected.

       

       

      • Bibiano_Geraldo's avatar
        Bibiano_Geraldo
        Icon for Super User rankSuper User

        Hi totamum 

        Please, for acurate solution, consider to share the measures used in both scenarios, for page views and for above and bellow.