count dates column

Forum home » Delegate support and help forum » Microsoft Power BI training and help » Count of dates in a column

Count of dates in a column

resolvedResolved · Medium Priority · Version 2016

Count of dates in a column

Afternoon,

I have a data table with two columns relevant to this query; a start date and a completion date. All lines have a start date and some lines have a completion date (which may be in the same month or a subsequent month)
I'm compiling a bar chart which totals the numbers started and completed for each calendar month.
I'm using a count of the start date column which is returning accurate values in the chart.
When I use the same count on the completion date I get a total figure which is less than the total I've manually counted in the table.
Do you know of any possible causes or things I could check?
I've reformatted the dates as MMM YY in an inserted column which hasn't had an effect.
Any help would be appreciated
Thanks
David

RE: Count of dates in a column

Hi David,

Thank you for the forum question.

Can I ask you to do two measure in Power Bi report.

TestCount=count([completion date] and TestCounta=counta([completion date]

Please let me know if both return the same result.

Do you use a Date table in your model?


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Count of dates in a column

Morning Jens,

Thanks for the speedy response. They both give the same value and I don't have a date table. Would using a date table resolve the issue? I'm going to be spending significant further time on this particular document so it's worth investing the time if it will prevent further problems.

Thanks

David

Edited on Fri 31 Jan 2020, 10:40

RE: Count of dates in a column

Hi David,

Yes we should have a date table in the model.

May I guess that you use the start date column as row input in the chart visual. Is this correct?

If you change it to completion date, then the count will be wrong for start date but right for completion date.

Add a Date table relate the must important date (start date or completion date) to the date table. Create a inactive relationship to the completion date (after you have created the relationship to start date create a relationship to completion date). You can recognise an inactive relationship be the dashed line.

All visuals which need to be group by date must be grouped be fields in the date table.

Now create two measures:

CountCompletionDate=Calculate(count([completion date],userelationship(Dates[date]),"the name of your table"[completion date]))

CountStartDate=Count("the name of your table"[start date])


Use the date from the date table and add the two measures to the chart.

Do you have a date table?

If not I am happy to send you one.

I don't want you to write your email address here, because it is a public forum, but send an email to info@stl-training.co.uk if you want me tp forward you my date table I use in all my data models.

Please type forward to Jens in the Subject

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Count of dates in a column

Afternoon Jens,

You're spot on with the chart row input on the chart. I compiled a date table earlier and have linked it as suggested.
The 2nd measure, start date works fine.
The first measure, completion date throws up the following syntax error:
Too few arguments were passed to the USERELATIONSHIP function. The minimum argument count for the function is 2.

The amended formula entered is:
CountCompletionDate = Calculate(count([completion date],userelationship(Dates[date]),NCR[completion date]))

Where NCR is the name of the data table

Any help you can provide would be appreciated

Thanks

David

RE: Count of dates in a column

Hi David,

It is just the brackets. Please try:



CountCompletionDate = Calculate(count([completion date]),userelationship(Dates[date],NCR[completion date]))


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Count of dates in a column

Hi David,

Sorry it is my fault. I did it wrong in my earlier answer.


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

 

Training courses

 

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Power BI tip:

Scheduled Refresh and Power BI Service

If you're using Power BI Service, set up scheduled refresh for your datasets. This ensures that your reports are always up-to-date with the latest data. Understand the refresh limits imposed by Power BI Service and optimize your data model and queries to stay within those constraints.

View all Power BI hints and tips


Server loaded in 0.07 secs.