Forum Discussion

o59393's avatar
o59393
Icon for Post Prodigy rankPost Prodigy
2 years ago

Count if with a measure

Hi

 

Is it possible to create a count if with a measure?

 

In the image below I have a capacity planning process with different activities (drilled down).

 

 

 

 

The rule is simple, if the % on each of the rows is above or equal to 0.8% then 1, else 0.

 

Also it should make the sum of the 1's for the process.  Hence the activities: capacity assessment, demand alignment and standard routines are the only ones who meet the criteria and should have a 1 next to each row, and the capacity assessment process should have a 3 (the sum of the 3 activities with a 1)

 

How can this be done in a dax?

 

The % column of the image has the following dax:

 

 

Non Duplicate Hours Process/Activity 3 = 

DIVIDE(
[Non Duplicate Hours Process/Activity Numerator],
[Non Duplicate Hours Process/Activity Denominator 3])

 

 

Thanks. 

 

 

 

 

 

13 Replies

  • You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

     

    • o59393's avatar
      o59393
      Icon for Post Prodigy rankPost Prodigy

      Hi lbendlin 

       

      With the second option you mention.

       

      The dax I am trying to reference has these 2 pieces:

       

      Non Duplicate Hours Process/Activity Numerator = 
      
      SUMX(
          SUMMARIZE(
              Template,
              Template[Merged],
              Template[Hours by Year]
              ),       
              Template[Hours by Year]
      )

       

      Could I have the if statetement incorporating these 2 measures within the dax?

       

      thanks.

    • o59393's avatar
      o59393
      Icon for Post Prodigy rankPost Prodigy

      lbendlin 

       

      Think I am getting closer:

       

       

      Any idea here why the red shows up ?

  • ITManuel's avatar
    ITManuel
    Icon for Responsive Resident rankResponsive Resident

    Hi o59393 ,

     

    not sure if I understood correctly, but if you want to count the facets which have & equal or greater to 0,8% you can try the following:

     

    Count IF =
    VAR _T1 = 
    FILTER (
        ADDCOLUMNS (
            VALUES ( Table[Facet] ),
            "@%", [Non Duplicate Hours Process/Activity 3]
        ),
        [@%] >= 0.8
    )
    VAR _Result = COUNTROWS ( _T1 )
    RETURN
    _T1
      • ITManuel's avatar
        ITManuel
        Icon for Responsive Resident rankResponsive Resident

        Sorry there is a mistake from my side. 

        Use _Result after RETURN instead of _T1