In this paper we prove a \(q\)-analogue of Koshy's formula in terms of the Narayana polynomial due to Lassalle and a \(q\)-analogue of Koshy's formula in terms of \(q\)-hypergeometric series due to Andrews by applying the inclusion-exclusion principle on Dyck paths and on partitions. We generalize these two \(q\)-analogues of Koshy's formula for \(q\)-Catalan numbers to that for \(q\)-Ballot numbers. This work also answers an open question by Lassalle and two questions raised by Andrews in 2010. We conjecture that if \(n\) is odd, then for \(m\ge n\ge 1\), the polynomial \((1+q^n){m\brack n-1}_q\) is unimodal. If \(n\) is even, for any even \(j\ne 0\) and \(m\ge n\ge 1\), the polynomial \((1+q^n)[j]_q{m\brack n-1}_q\) is unimodal. This implies the answer to the second problem posed by Andrews.