Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX help - filtering?

Hi all

 

New to Power BI here and complete novice when it comes to DAX! Would really appreciate any help.

 

I'm trying to use 'calculate' and 'filter' but keep getting error messages. Using the example below, i'd like to count up the amount of times 'red' 'orange' and 'yellow' appear in the column 'Colour' below (6 times), but also say 'light' in the column 'Light or dark' (4 times).

 

Can anyone help me with the correct expression to achieve this?

 

Thanks in advance.

 

ColourLight or Dark
RedLight
OrangeDark
YellowLight
BlueDark
RedDark
OrangeLight
YellowLight
PurpleDark

 

  • Hi Anonymous ,

     

    Create a measure with below code:-

    measure =
    COUNTROWS (
        FILTER (
            'Table (4)',
            'Table (4)'[Colour]
                IN { "Red", "Orange", "Yellow" }
                && 'Table (4)'[Light or Dark] = "Light"
        )
    )

     

    Output:-

     

    Thanks,

    Samarth

     

2 Replies

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi Anonymous ,

     

    Create a measure with below code:-

    measure =
    COUNTROWS (
        FILTER (
            'Table (4)',
            'Table (4)'[Colour]
                IN { "Red", "Orange", "Yellow" }
                && 'Table (4)'[Light or Dark] = "Light"
        )
    )

     

    Output:-

     

    Thanks,

    Samarth

     

  • Anonymous , Create a measure like

     

    calculate(count(Table[Colour]), filter(Table, Table[Colour] in {"red", "orange","yellow"} && Table[Light or Dark] ="Light"))