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
pe2950
Helper I
Helper I

Calculating Close Ratio across two date columns?

I'm trying to calculate a conversion ratio, using two date columns, across a specific time period.

 

Deals Data Table (Columns):

created_at (DATE/TIME, NOT NULL)
closed_date (DATE/TIME, NULL)

deal_status_id (STRING, NOT NULL)

employee_id (STRING, NOT NULL)

 

I've created a DateKey table and setup two relationships with the cross filter set to single for both.

DateKey[Date] (1) > Deals[created_at] (many) (active)

DateKey[Date] (1) > Deals[closed_date] (many)

 

The measures i've created to perform the calculation:

 

 

 

 

Created Deals = CALCULATE (COUNTROWS(deals),  USERELATIONSHIP(deals[created_at], DateKey[Date] ) )Won Deals = CALCULATE (countrows(deals), deals[deal_stage_id]=3000149092, USERELATIONSHIP (  deals[closed_date],  DateKey[Date]) ) 

 

 

 

 

 Close Ratio = ([Won Deals] / [Created Deals]) 

 

 

 

 

 

The issue i'm facing relates to calculating the data for a specific time period.

  • If i put a date slicer linked to DateKey[Date], and set it to this year; I would expect the measures to calculate for the year, intead I don't get anywhere near it.
  • For example, if i drop a date slicer linked to deals[created_at] and set it to this year, for employee-a i get a value of 519. This is correct. If i do the same and use a slicer for deals[closed_date] and set it to this year, for employee-a i get a value of 307 - also correct.
  • When i do the same with the DateKey[Date] slicer, i'm getting created_at = 0; closed_at = 307

    I've also tried to write time-specific DAX, but I get an error saying there are duplicate date values (which i don't quite understand):

     

 

 Won_YTD = CALCULATE(COUNTROWS(deals), USERELATIONSHIP( deals[closed_date], DateKey[Date]), deals[deal_stage_id]=3000149092, DATESYTD(deals[closed_date])) 

 

 

The above works properly... but...

 

 

 Won_YTD = CALCULATE(COUNTROWS(deals), USERELATIONSHIP( deals[created_at], DateKey[Date]), DATESYTD(deals[created_at])) 

 

 

Gives me an error about duplicate dates - Suggestions?

 

 

 

 

 

 

 

 

 

 

1 REPLY 1
v-xiaosun-msft
Community Support
Community Support

Hi @pe2950 ,

 

When you do the same with the DateKey[Date] slicer, please try to change the relationship between two tables to many>1.

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you. 

 

Best Regards,
Community Support Team _ xiaosun

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.