
VAR CurrentCompany = SELECTEDVALUE(COMPANIES[COMPANYID])  -- Get the current company ID
VAR Industry = SELECTEDVALUE(COMPANIES[INDUSTRY])  -- Get the current industry

RETURN
    CALCULATE(
        COUNTROWS(COMPANIES),  -- Count the number of companies
        COMPANIES[INDUSTRY] = Industry,  -- Filter by the current industry
        COMPANIES[COMPANYID] <> CurrentCompany  -- Exclude the current company
    )