Search code examples
databasebusiness-intelligencecognos

Create calculated measure in cognos framework manager using count function with condition


I have a database for hotels and each record represents a hotel with different facts related to this specific hotel for example the grading the category of the hotel whether hotel or hotel apartments etc..., What i want to do is to count all the records with the 'Hotel' Accom Type how can i achieve this as i tried to do it using count but it counts all the records not the ones with the Accom Type I look for attached a screenshot of the records, Any Help will be appreciated

The Table snap


Solution

  • Two patterns:

    COUNT(
        CASE [Accom Type] 
        WHEN 'Hotel' THEN [Accom Type] 
        ELSE null
        END
    )
    

    or

    TOTAL(
        CASE [Accom Type] 
        WHEN 'Hotel' THEN 1 
        ELSE 0 
        END
    )