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
SadStatue
Helper II
Helper II

Employment conversion rate measure calculation

Dear community,

 

Below you can find the data related to a recruitment process. What I want is to calculate a conversion rate between 2 phase of this process (Stat 11 to 20).

TimestampReference IDNamestathighlighted
7/08/2020 0:04C_a118name11471 
14/08/2020 16:08C_a118name114711X
27/08/2020 9:45C_a118name114720 
7/08/2020 2:32C_a118name12911 
4/08/2020 14:12C_a118name063011X
6/10/2020 13:15C_a127name03251 
22/09/2020 10:52C_a127name054411 
21/08/2020 2:49C_a129name13231 
22/09/2020 15:51C_a129name132311X
14/09/2020 9:14C_a129name132411X
12/10/2020 9:24C_a129name132320 
14/10/2020 9:14C_a129name132611 

each time the stat column change we record it in a row with a time stamp. Refrence_ID shows the position we want to recruit and name is the name of the applicant. and stat show the status of applicant for the process. what I want to calculate is the conversion rate between stat 11(just those records with the stat of 11 that highlighted with X should be counted for my measure) to 20.

Conversion rate = (distinct number of applicant who have stat of 20) / (distinct number of applicants who have stat of 11 for the same positions that somebody get stat 20 and with a time stamp equal or less than the max timestamp of the person get stat 20 for that position)

 

for this very little example the result should be sth like this:

conversion rate=2/4=0.5

 

Does anyone can help me write the related dax measure?

 

Thank you in advance for your help and support!

 

Here you can find the sample nad real data !

1 ACCEPTED SOLUTION

Hi @SadStatue,

 

I updated the demo, please refer: Employment-conversion-rate-measure-calculation 

Here is the output:

v-xulin-mstf_0-1611717882675.png

 

Best Regards,

Link

 

View solution in original post

15 REPLIES 15
v-xulin-mstf
Community Support
Community Support

Hi @SadStatue,

 

Create two measures as:

Measure =

var _reference=CALCULATE(MAX('Table'[Reference ID]),FILTER('Table','Table'[Molecular]=1))

var _datestamp=CALCULATE(MAX('Table'[Timestamp]),FILTER('Table','Table'[Molecular]=1 && 'Table'[Reference ID]=_reference))

var  a=CALCULATETABLE(VALUES('Table'[Name]),FILTER(ALL('Table'), 'Table'[stat]=20))

var  b=CALCULATETABLE(VALUES('Table'[Name]),FILTER(ALL('Table'),'Table'[Timestamp]<_datestamp && 'Table'[stat]=11&&'Table'[Reference ID]=_reference))

Return

COUNTROWS(a)/COUNTROWS(b)
Molecular =

IF(MAX('Table'[stat])=20,1,0)

Here is the output:

v-xulin-mstf_0-1610963969924.png

 

Here is the demo, please try it: Employment conversion rate measure calculation

 

Best Regards,

Link

Hi @v-xulin-mstf 

 

Thank you so much for your time and effort on my problem.

i dont think its working as I implement it for the data I've mentioned in the main post and it brings infinity. So I believe variable "b" is not calculating as we want.

 

Cheers,

Hi @SadStatue,

I have modified the measure.

Here is the output:

1.png

Here is the demo, please try it: Employment conversion rate measure calculation

 

Best Regards,

Link

Hi @v-xulin-mstf ,

Thank you so much for your time and review.

I believe we get closer to the soloution, but the issue with the current measure is that we get the max refrenceID. so it works if we filter by refrenceID but when we want it for all the refrence IDs its not working as it consider the max one.

in fact we need to calculate "a" and "b" for each refrence ID and then calculate Sum(a)/Sum(b)
we may use the function Earlier, but im not sure how should I use it.

Cheers,

Hi @SadStatue,

 

I'm not sure if you don't want to group by "refrenceID" but to count the total.

Maybe the measure below works:

Measure = 
var _reference=CALCULATE(MAX('Table'[Reference ID]),FILTER('Table','Table'[stat]=20))
var _datestamp=CALCULATE(MAX('Table'[Timestamp]),FILTER('Table','Table'[stat]=20 && 'Table'[Reference ID]=_reference))
var  a=CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        ALL('Table'),
        'Table'[stat]=20
    )
)
var  b=CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        ALL('Table'),
         'Table'[stat]=11 && 'Table'[Timestamp]<=_datestamp
    )
)
Return
a/b

 

Best Regards,

Link

Hi @v-xulin-mstf ,

Thank you for your response. But I dont think it works properly as we released the condition of Refrence ID. I still want to calculate number of stat 11 just for those refrences that had stat 20.
I'm not sure how groupby can help me in this situation. but I need the number of records.


Cheers,

Hi @SadStatue,

I'm not clear.

For example, if you want to calculate (count of green mark)/(count of blue mark) when i select C_a129.

v-xulin-mstf_0-1611299180287.png

 

Best Regard,

Link

Hi @v-xulin-mstf ,

Thanks for your response.

it works if we select a single Reference ID, but it wont work if we dont filter it by a single Ref ID. And I want it to work generaly.

below example is more comprehensive:

SadStatue_0-1611700910494.png

So I want the (count of red underlined)/(count of highlighted).

Cheers,

Hi @SadStatue,

 

I updated the demo, please refer: Employment-conversion-rate-measure-calculation 

Here is the output:

v-xulin-mstf_0-1611717882675.png

 

Best Regards,

Link

 

Hi@v-xulin-mstf 

Thanks for your response. I used your suggested solution but I noticed that its not working properly!! as we manage part of the filtering in a column which make it so undynamic!
I believe we have to manage the whole filtering and calculation in measure level and not in the columns as I want to show these conversion rates in bar chart (conversion rate per month).
so it calculate all the record with stat 20 and devide by all record with stat 11 and column=1. so our measure fail to filter stat 11s that have the same reference_ID (position).
It would be great if you can have another look on it

Cheers,

 

Hi @v-xulin-mstf ,

Thank you so much for your time and effort to find the solution. Its woorking perfectly.

 

Cheers,

Hi,

So the numerator has to be the count of all rows that have 20 in the stat column and the denominator has to be all rows that have 11 in the stat column.  Am i correct?  Share the link from where i can download your PBI file.


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

Hi @Ashish_Mathur ,

Thank you for your comment. No I have some more considerations in calculation of this conversion rate. I want to find the rate that 11 (Interviewed applicant) turned to 20 (Employed). So there should be an 20 for counted 11 (on the same ref ID/job position) and also the 11 time stamp should be before the time stamp of related (on the same ref ID) 20 .
in the sample data there are two 11 that I dont want to count as below:

SadStatue_1-1611714449968.png

You can find the whole data here, but lets start working with the sample data.

amitchandak
Super User
Super User

@SadStatue , Try a measure like

 

divide(calculate(distinctcount(Table[Name]), filter(Table, Table[stat] = 20)),calculate(distinctcount(Table[Name]), filter(Table, Table[stat] = 11)))

Hi @amitchandak 

 

Thank you for your quick response.

No it wont work as u just simply filter just by stat while I have 2 more conditions (it is 2/6=0.33 which is not what I want)

1. Calculating number of applicant with stat 11 for the same positions(Reference ID) that sb get stat 20

2. Time stamp of records with stat 11 should be equal or before the time stamp of the records with stat 20 for that position (Reference ID)

I've amended the main post sample data and marked those records with sat of 11 that want to be calculated in my measure with X. As u see there are 2 records with stat of 11 which is not marked one of them is for C_a 127, as no one get stat 20 for this reference ID (position) and the other one is the last line record, and its not marked as its time stamp is after the time stamp of the record one to last (the one that have stat 20 for the same refrence ID)

You can also find the whole data and a larger sample data in the hyper link of the main post.

 

I hope I could shed some light on the issue by this extra description.

 

Cheers,

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.