Forum Discussion

TonyGoose_001's avatar
TonyGoose_001
New Member
2 years ago
Solved

Divide measure that excludes values without Calculate

Hi

 

I wish to amend the following query to exlcude "No" from the numerator as well as the demoninator. However if I use CALCULATE to try and achieve this it loses the context and sets all values to 1 (or 100%) within my matrix. How do I exclude "No" from the numerator?

 
% of Responses = 
IF(
ISINSCOPE(Survey[Responses]),
DIVIDE(
COUNTA(Survey[Responses]),
CALCULATE(
COUNTA(Survey[Responses]),
Survey[Responses] <> "No",
REMOVEFILTERS(Survey[Responses])
)
)
)
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, TonyGoose_001 

    You can try this measure to achieve your need.


    Measure:

    % Responses = 
    VAR _countOfResponses =
        CALCULATE (
            COUNT ( 'Table'[Responses] ),
            FILTER ( 'Table', 'Table'[Responses] <> "BLANK" )
        )
    VAR _allCountsOfResponses =
        CALCULATE ( COUNT ( 'Table'[Responses] ), 'Table'[Responses] <> "BLANK" )
    VAR _result =
        IF (
            NOT ISBLANK ( _countOfResponses ),
            DIVIDE ( _countOfResponses, _allCountsOfResponses )
        )
    RETURN
        _result
    

     

    Best Regards,
    Yang

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know.
    Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, TonyGoose_001 

    You can try the following measure.

    % of Responses = 
    IF(
        ISINSCOPE(Survey[Responses]),
        DIVIDE(
            COUNTA(FILTER(Survey, Survey[Responses] <> "No")),
            COUNTA(FILTER(ALL(Survey), Survey[Responses] <> "No))
        )
    )
    

     

    If this does not work, could you please share some sample data without sensitive information and expected output.

    Best Regards,
    Yang

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know.
    Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

     

    • TonyGoose_001's avatar
      TonyGoose_001
      New Member

      Hi v-yaningy-msft

       

      Thanks for your response. Sadly that didn't work. It states that counta will only accept a column reference as an argument. However I have done as you have suggested, below is some made up sample data to illustrate the problem (i hope I've done that correctly).

      Also, here's a picture of the aspect I would like to change with an example highlighted. I want to retain the count of BLANKS but remove them from the percentages. For the highlighted example the answer would read:

      Telephone 80%

      Face to Face 20%

       

      Reply IDSurvey DateQuestionsResponses
      161423-Apr-241. How was the data collected?1 Telephone
      161423-Apr-242. How satisfied or dissatisfied are you with the service provided?1 Very satisfied
      161423-Apr-243. Has work been carried out to your home in the last 12 months?1 Yes
      77001-Apr-241. How was the data collected?1 Telephone
      77001-Apr-242. How satisfied or dissatisfied are you with the service provided?2 Fairly satisfied
      77001-Apr-243. Has work been carried out to your home in the last 12 months?1 Yes
      40401-Apr-241. How was the data collected?BLANK
      40401-Apr-242. How satisfied or dissatisfied are you with the service provided?2 Fairly satisfied
      40401-Apr-243. Has work been carried out to your home in the last 12 months?1 Yes
      211217-Apr-241. How was the data collected?3 Face to Face
      211217-Apr-242. How satisfied or dissatisfied are you with the service provided?1 Very satisfied
      211217-Apr-243. Has work been carried out to your home in the last 12 months?1 Yes
      538023-Apr-241. How was the data collected?1 Telephone
      538023-Apr-242. How satisfied or dissatisfied are you with the service provided?1 Very satisfied
      538023-Apr-243. Has work been carried out to your home in the last 12 months?2 No
      163023-Apr-241. How was the data collected?1 Telephone
      163023-Apr-242. How satisfied or dissatisfied are you with the service provided?1 Very satisfied
      163023-Apr-243. Has work been carried out to your home in the last 12 months?1 Yes

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi, TonyGoose_001 

        You can try this measure to achieve your need.


        Measure:

        % Responses = 
        VAR _countOfResponses =
            CALCULATE (
                COUNT ( 'Table'[Responses] ),
                FILTER ( 'Table', 'Table'[Responses] <> "BLANK" )
            )
        VAR _allCountsOfResponses =
            CALCULATE ( COUNT ( 'Table'[Responses] ), 'Table'[Responses] <> "BLANK" )
        VAR _result =
            IF (
                NOT ISBLANK ( _countOfResponses ),
                DIVIDE ( _countOfResponses, _allCountsOfResponses )
            )
        RETURN
            _result
        

         

        Best Regards,
        Yang

        Community Support Team

         

        If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
        If I misunderstand your needs or you still have problems on it, please feel free to let us know.
        Thanks a lot!

        How to get your questions answered quickly --  How to provide sample data in the Power BI Forum