Forum Discussion

mcijerry's avatar
mcijerry
New Member
1 year ago
Solved

A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expre

Getting the error when trying to calculate the percentage of distinct users [REGEID] with more than one device [ID]

Error: A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

Measure:

PercentageOfUsersWithMoreThan2Endpoints =
VAR EmployeesWithMoreThan2Computers =
    CALCULATETABLE(
        VALUES('EPD Endpoints'[RegEID]),
        CALCULATE(
            COUNT('EPD Endpoints'[ID]),
            ALLEXCEPT('EPD Endpoints', 'EPD Endpoints'[RegEID])
        ) > 1
    )
 
VAR CountOfEmployeesWithMoreThan2Computers = COUNTROWS(EmployeesWithMoreThan2Computers)
VAR DistinctEmployeeCount = DISTINCTCOUNT('EPD Endpoints'[RegEID])
 
RETURN
    DIVIDE(DistinctEmployeeCount, CountOfEmployeesWithMoreThan2Computers, 0)
  • mcijerry Try using

     

    DAX
    PercentageOfUsersWithMoreThan2Endpoints =
    VAR EmployeesWithMoreThan2Computers =
    FILTER(
    VALUES('EPD Endpoints'[RegEID]),
    CALCULATE(
    COUNT('EPD Endpoints'[ID]),
    ALLEXCEPT('EPD Endpoints', 'EPD Endpoints'[RegEID])
    ) > 1
    )

    VAR CountOfEmployeesWithMoreThan2Computers = COUNTROWS(EmployeesWithMoreThan2Computers)
    VAR DistinctEmployeeCount = DISTINCTCOUNT('EPD Endpoints'[RegEID])

    RETURN
    DIVIDE(CountOfEmployeesWithMoreThan2Computers, DistinctEmployeeCount, 0)

4 Replies

  • mcijerry Try using

     

    DAX
    PercentageOfUsersWithMoreThan2Endpoints =
    VAR EmployeesWithMoreThan2Computers =
    FILTER(
    VALUES('EPD Endpoints'[RegEID]),
    CALCULATE(
    COUNT('EPD Endpoints'[ID]),
    ALLEXCEPT('EPD Endpoints', 'EPD Endpoints'[RegEID])
    ) > 1
    )

    VAR CountOfEmployeesWithMoreThan2Computers = COUNTROWS(EmployeesWithMoreThan2Computers)
    VAR DistinctEmployeeCount = DISTINCTCOUNT('EPD Endpoints'[RegEID])

    RETURN
    DIVIDE(CountOfEmployeesWithMoreThan2Computers, DistinctEmployeeCount, 0)

    • mcijerry's avatar
      mcijerry
      New Member

      Interesting and almost there, the Measure at least passes inspection (and for the life of me I tried using FILTER everyewhere in the measure but did not know where to put it and to use it in place of CalculateTable)

      Only issue now is I get 640.11 %  🙂

  • Impressive Bhanu, thank you sir.  Now, on to see how to get rid of "blank" coming back on my gauge when percentage is 0