Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Adding condition for DAX calculate and filter expression

Hi all,

 

I am working on creating a Title card for my dynamic report and need some help.

 

I have a list of holding companies and I want to create an expression that will allow the user to filter and pick an account and to automatically see the account's holding company in a card. I have been able to create the expression successfully:

 

Title = "Report C-" & CALCULATE(FIRSTNONBLANK(Table1[account], TRUE () ), FILTER (Table1, Table1[HoldingCompany] = TRUE ())

 

However, I also want to add a condition that if no account is picked, then the title card should say 'All Accounts". How do I add that condition in the expression? I keep getting an error when I try. Appreciate the help! Thank you

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler Hi Greg, I'm not sure I fully understand the measure. I just want to add "All Accounts" at the end of the measure? 

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Anonymous Not much to go on but maybe:

        Title = 
          VAR __TOTAL_ROWS = COUNTROWS(DISTINCT(ALL('Table1'[account])))
          VAR __CURRENT_ROWS = COUNTROWS(DISTINCT('Table1'[account]))
        RETURN
          IF(__TOTAL_ROWS = __CURRENT_ROWS(
            "All accounts",
            "Report C-" & CALCULATE(FIRSTNONBLANK(Table1[account], TRUE () ), FILTER (Table1, Table1[HoldingCompany] = TRUE ())
          )