Forum Discussion

raymond's avatar
raymond
Post Patron
7 years ago

Measure with Variables and Filters

Hi,

I have simpliefied my example. I want to calculate the number of E-Mail Opens with a filter for "Welcome-Phase". Of course there are other phases as well such as "Follow Up". It works fine though BUT when I display it in a matrix or table with a the column "Phase", every row contains the same value. Whereas there should be only a value for "Welcome-Phase" and e.g. a 0 for "Follow Up". 

 

Does anyone have solution how to get to the correct value?

 

SCORE = 
VAR score =
    CALCULATE(
        [mailing-opens] ;
        [Phase] IN {"Welcome-Phase"} ;
        [Art] IN {"Initial"}
        )

RETURN
score

6 Replies

  • dedelman_clng's avatar
    dedelman_clng
    Community Champion

    By putting the column [Phase] in a matrix/table, you are adding the filters implicitly in the visualization and don't need them in the measure.

     

    So your code should be

     

    SCORE = 
    VAR score =
        CALCULATE(
            [mailing-opens] ;
            [Art] IN {"Initial"}
            )
    
    RETURN
    score

    (if you are putting [Art] in the visual as well, you can remove the measure altogether as you would just use [mailing-opens] as the value

     

    Hope this helps

    David

    • raymond's avatar
      raymond
      Post Patron

      dedelman_clng Thank you.

       

      However, what if the following is the case :)

       

      SCORE = 
      
      VAR scoreA =
          CALCULATE(
              [mailing-opens] ;
              [Phase] IN {"Welcome-Phase"} ;
              [Art] IN {"Initial"}
              )
      
      VAR scoreB
          CALCULATE(
              [mailing-klicks] ;
              [Phase] IN {"Welcome-Phase"} ;
              [Art] IN {"Result"}
              )
      
      RETURN
      scoreA + scoreB

       

      What I hope to see in a matrix table is the Result of scoreA + scoreB for the "Welcome-Phase" and in a drill down to "Art" the separate values for "Result" and "Initial"

      • dedelman_clng's avatar
        dedelman_clng
        Community Champion

        Can you provide a sample of data and your expected results?