Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
niharikaavasthi
Regular Visitor

Need help in finding date from a daterange

I have 3 columns which I ma taking from 2 tables. 

Start date and end date from contract table

reqquestdatetime from workorder table.

I need count of workorders if my requestdatetime is lying in the range of startdate and enddate

I used - 

COUNT WO = CALCULATE(COUNT(WO[WorkOrder_IncidentNumber]),DATESBETWEEN(WO[WorkOrder_RequestDateTime],Contract[StartDate],Contract[EndDate]))
but giving me error "A single value for column 'StartDate' in table 'Contract' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
How can I use aggregate function in dates
3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @niharikaavasthi ,

It seems that you are creating a measure and you can refer to user @smpa01 's suggestion to update your measure formula. Or you can refer to the solution in the posts below to correct your formula and check later to see if you get the correct value...

1. Create a calculated column replace with original measure 

single value for column error

2. Use the aggregation

A single value for column 'Open_Date_Time__c' in table 'Problem' cannot be determined

If the above methods do not help you to get the desired result, please provide some sample data of the Contract and WO tables and your final desired result with specific examples and calculation logic. Also, is there any relationship created between these two tables? Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
smpa01
Super User
Super User

@niharikaavasthi  try this

 

_count =
CALCULATE (
    COUNT ( WO[WO] ),
    DATESBETWEEN ( WO[Date], MAX ( Contract[Start] ), MAX ( Contract[End] ) )
)
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.