Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

filtering matrix by columns

Hi, 

 

I have a matrix like this (column month row client id and value sales) and I want to filter only the rows which has non blank in each column (1000006861 and 1000011110 would be filtered)

Thanks a lot,

 

Marcos Pérez

  • AlB's avatar
    AlB
    7 years ago

    Anonymous 

    Try placing this measure in a card visual:

     

     

    BoughtInEneroAndFebrero =
    VAR _BoughtInEnero =
        CALCULATETABLE ( DISTINCT ( Table1[IDCLIENTE] ), Table1[MES] = "Enero" )
    VAR _BoughtInFebrero =
        CALCULATETABLE ( DISTINCT ( Table1[IDCLIENTE] ), Table1[MES] = "Febrero" )
    RETURN
        COUNTROWS ( INTERSECT ( _BoughtInEnero, _BoughtInFebrero ) )

     

    I'm assuming that an IDCLIENTE will only come up in the table for a specific month if there have been sales (i.e. it cannot be the case that you have a blank in IMPORTE 

4 Replies

  • AlB's avatar
    AlB
    Community Champion

    Hi Anonymous 

    This would probably be easier and more convenient if you unpivoted the month columns.

    In any case, with this structure, you could create a new calculates table as follows, where Table1 is the table that you show. Add more months if necessary, following the same pattern.

     

    NewTable =
    FILTER (
        Table1,
        Table1[Enero] <> BLANK () && Table1[Febrero] <> BLANK ()
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi AlB, In fact I have already the data unpivotted like this. What I want is to know the number of clients who have bought in both months. Thanks! 

       

      • AlB's avatar
        AlB
        Community Champion

        Anonymous 

        Try placing this measure in a card visual:

         

         

        BoughtInEneroAndFebrero =
        VAR _BoughtInEnero =
            CALCULATETABLE ( DISTINCT ( Table1[IDCLIENTE] ), Table1[MES] = "Enero" )
        VAR _BoughtInFebrero =
            CALCULATETABLE ( DISTINCT ( Table1[IDCLIENTE] ), Table1[MES] = "Febrero" )
        RETURN
            COUNTROWS ( INTERSECT ( _BoughtInEnero, _BoughtInFebrero ) )

         

        I'm assuming that an IDCLIENTE will only come up in the table for a specific month if there have been sales (i.e. it cannot be the case that you have a blank in IMPORTE