This content is now out of date.

Visit Our Community

Calcualted Field for a Count

What is the best way to create a calculated field for a count? I tried just dragging a Metric Calculated field onto the available fields, using a formula of 1 with an aggregate of sum. However, this has mixed results. It doesn't count right on a report when it is the only metric in a report. But seems to work when there are other metrics. Did I stumble on a bug or is there another suggested way to do this?

Hi Clayton

I believe this forum post contains the solution you looking for

Not quite. I just want add a count field in my Data Source View so it is available from any report and you can drag it in as a field to get a count of fact table record for any level of grouping that your are doing in the report. I believe I found a way to do this. I create a calculated metric field, and the formula is count ( [any field in fact table ] ) And then I make the aggregate a count. It seems a little counterintuitive but it appears to work now.
Hi Clayton,

Glad you found a solution that works for you.

I must have misunderstood the question, thought you wanted row numbers.
I would have done something similar, create a Calculated field at View level, to return 1, and then you apply count as the default aggregation.