
VAR CurrentCompany = SELECTEDVALUE(COMPANIES[COMPANYID])  -- Get the current company ID
VAR Sector = SELECTEDVALUE(COMPANIES[SECTOR])  -- Get the current sector

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