Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX - IF, AND & OR

Hello -   I'm trying to write a DAX formula but seem to be falling short, not sure if this can be achieved by 'adding a new column' within BI:    Example Question: Within the UK, we have X amoun...
  • PijushRoy's avatar
    4 years ago

    Hi Anonymous 

    Try this one

    Column = SWITCH(
    TRUE(),
    'Table'[Country] = "UK" && 'Table'[Gender] = "Female" && 'Table'[Ethnicity]="Black" || 'Table'[Ethnicity]="Arabic", "Yes",
    "No")
     
    Then you can countrows
    = Calculate(Count('Table'[Country]),'Table'[Column] = "Yes")

    If you have any question, please let me know.
    If solve your requirement, please mark this answer as SOLUTION
    If this comment helps you, please LIKE this comment/Kudos
  • bcdobbs's avatar
    4 years ago

    You could do it with a calculated column but I would suggest a measure like:

    # Needed = 
        CALCULATE (
            COUNTROWS ( Sheet1 ),
            Sheet1[Ethnicity] IN { "Black", "Arabic" },
            Sheet1[Gender] = "Female"
        )