Count and use the number of items in advance

I am not sure how to do it with itemize. But with enumerate environment you could add a label to last item.

\documentclass{article}

\begin{document}
There are \ref{lst:num} ways how a parameter can be given:
\begin{enumerate}
    \item By a constant expression.
    \item By user interaction.
    \item From another database. 
    \label{lst:num}
\end{enumerate}

\end{document}

Here's a way: we modify the itemize environment with etoolbox tools; each \item command will step a counter; every environment steps another. A couple of LaTeX runs can be necessary for the numbers to stabilize.

\documentclass{article}
\usepackage{etoolbox,refcount}

\newcounter{countitems}
\newcounter{nextitemizecount}
\newcommand{\setupcountitems}{%
  \stepcounter{nextitemizecount}%
  \setcounter{countitems}{0}%
  \preto\item{\stepcounter{countitems}}%
}
\makeatletter
\newcommand{\computecountitems}{%
  \edef\@currentlabel{\number\c@countitems}%
  \label{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\newcommand{\nextitemizecount}{%
  \getrefnumber{countitems@\number\c@nextitemizecount}%
}
\makeatother
\AtBeginEnvironment{itemize}{\setupcountitems}
\AtEndEnvironment{itemize}{\computecountitems}

\begin{document}

There are \nextitemizecount{} ways how a parameter can be given:
\begin{itemize}
\item By a constant expression.
\item By user interaction.
\item From another database.
\end{itemize}

There are \nextitemizecount{} ways how a parameter can be given:
\begin{itemize}
\item By a constant expression.
\item By user interaction.
\item From another database.
\item Foo.
\end{itemize}

The next doesn't count.

\begin{itemize}
\item A
\item B
\end{itemize}

There are \nextitemizecount{} ways how a parameter can be given:
\begin{itemize}
\item By a constant expression.
\item By user interaction.
\end{itemize}

\end{document}

enter image description here


With the help of the enumitem package you can define a list based on enumerate, but behaving as itemize as far as labels are concerned. In this way one is allowed to place \labels, in particular to the last item. The following example illustrates such definition (for a list environment with four-level nesting) and also shows that the approach works with nesting:

\documentclass{article}
\usepackage{enumitem}

\newlist{citemize}{enumerate}{4}
\setlist[citemize,1]{label=$\bullet$,ref=\arabic*}
\setlist[citemize,2]{label=--,ref=\arabic*}
\setlist[citemize,3]{label=$\ast$,ref=\arabic*}
\setlist[citemize,4]{label=$\cdot$,ref=\arabic*}

\begin{document}

There are~\ref{lst:num} ways how a parameter can be given, and user interaction has~\ref{lst:subnum} possibilities:
\begin{citemize}
  \item By a constant expression.
  \item By user interaction.
  \begin{citemize}
    \item First subitem.
    \item Second subitem.
    \label{lst:subnum}
  \end{citemize}
  \item From another database. 
  \label{lst:num}
\end{citemize}

\end{document}

enter image description here