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

Calculate conversions as a measure

Pretty new to Power BI so hoping for some help on creating a measure.

I have a table (Engagement) of sales activity data, consisting of one row per activity. I'd like to divide the number of meetings booked (engagement_type = MEETING) by the number of calls (engagement_type = CALL) on any given day, creating a daily conversion rate measure. How would I go about doing that?

 

3 ACCEPTED SOLUTIONS

Hi @enorberg ,

If you have the same structure with the table in below screenshot, you can create one similar measure using DIVIDE function  just like this:

 

 

Ratio = var nm=CALCULATE(DISTINCTCOUNT('Engagement'[Index]),FILTER(ALL('Engagement'),'Engagement'[Engagement_type]="MEETING"&&'Engagement'[Engagement Date]=SELECTEDVALUE('Engagement'[Engagement Date])))  //get the number of meetings on a specific date
var nc=CALCULATE(DISTINCTCOUNT('Engagement'[Index]),FILTER(ALL('Engagement'),'Engagement'[Engagement_type]="CALL"&&'Engagement'[Engagement Date]=SELECTEDVALUE('Engagement'[Engagement Date])))  //get the number of calls on a specific date
return DIVIDE(nm,nc)

 

 

divide.PNG

If the above measure is not applicable in your scenario, please provide the related table structure and more sample data(exclude sensitive data).

Best Regards

Rena

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.

View solution in original post

Hi @enorberg,

I don't know if you noticed there was a condition in that formula: 'Engagement '[Engagement Date] = SELECTEDVALUE (' Engagement '[Engagement Date])... The SELECTEDVALUE (' Engagement '[Engagement Date]) corresponds to the date selected by the slicer in the screenshot in my previous post. There is no slicer in your screenshot, which means no returned value. Hence there is no data display in the visual... In addition, I found there is one error about your formula. We need to count the number of meetings not the number of meeting type, so you need to update the formula from DISTINCTCOUNT('Engagement'[engagement_type]) to 'DISTINCTCOUNT('Engagement'[engagementid]) . Please complete the steps in below screenshot:

1. Add one slicer with Field "engagement_date"

2. Update the formula as below:

Ratio = var nm=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="MEETING"&&'Engagement'[engagement_date]=SELECTEDVALUE('Engagement'[engagement_date]))) 
var nc=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="CALL"&&'Engagement'[engagement_date]=SELECTEDVALUE('Engagement'[engagement_date])))
return DIVIDE(if(ISBLANK(nm),0,nm),if(ISBLANK(nc),1,nc))

divide2.JPG

The following documentations describe the details of these functions applied in the formula:

https://docs.microsoft.com/en-us/dax/distinctcount-function-dax

https://docs.microsoft.com/en-us/dax/selectedvalue-function

https://docs.microsoft.com/en-us/dax/filter-function-dax

https://docs.microsoft.com/en-us/dax/divide-function-dax

Best Regards

Rena

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.

View solution in original post

Hi @enorberg ,

Please try to update the formula as below:

Ratio = var nm=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="MEETING"&&'Engagement'[engagement_date] in VALUES('Engagement'[engagement_date]))) 
var nc=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="CALL"&&'Engagement'[engagement_date] in VALUES('Engagement'[engagement_date])))
return DIVIDE(if(ISBLANK(nm),0,nm),if(ISBLANK(nc),1,nc))

Best Regards

Rena

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.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @enorberg,

 

You can use a calculated measure that would look like this:

 

 

DIVIDE(CALCULATE(SUM([FIELD]),[TYPEFIELD]="MEETING"),CALCULATE(SUM([FIELD]),[TYPEFIELD]="CALL"),0)

 

 

This would divide the sum filtered by the type Meeting for the sum filtered by the type call.

 

Let me know if it helped.

 

Best Regards,

DR 

 

HI @Anonymous ,

Many thanks for your help and apologies for the late reply.

I just tried your solution and ran into some trouble. What is the difference between 'FIELD' and 'TYPEFIELD' in your example? I've successfully replaced 'FIELD' with 'engagement_type' but didn't manage with 'TYPEFIELD' (error). What am I missing?

Thanks 🙂

Hi @enorberg ,

If you have the same structure with the table in below screenshot, you can create one similar measure using DIVIDE function  just like this:

 

 

Ratio = var nm=CALCULATE(DISTINCTCOUNT('Engagement'[Index]),FILTER(ALL('Engagement'),'Engagement'[Engagement_type]="MEETING"&&'Engagement'[Engagement Date]=SELECTEDVALUE('Engagement'[Engagement Date])))  //get the number of meetings on a specific date
var nc=CALCULATE(DISTINCTCOUNT('Engagement'[Index]),FILTER(ALL('Engagement'),'Engagement'[Engagement_type]="CALL"&&'Engagement'[Engagement Date]=SELECTEDVALUE('Engagement'[Engagement Date])))  //get the number of calls on a specific date
return DIVIDE(nm,nc)

 

 

divide.PNG

If the above measure is not applicable in your scenario, please provide the related table structure and more sample data(exclude sensitive data).

Best Regards

Rena

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.

Hi @v-yiruan-msft ,

Many thanks for trying to help. I've been working on using your solution, but it doesn't seem to work:

 

screen1.PNG

 

Here is some sample data (displaying calls only):

 

sample data.PNG

 

What am I doing wrong here? Thanks

Hi @enorberg,

I don't know if you noticed there was a condition in that formula: 'Engagement '[Engagement Date] = SELECTEDVALUE (' Engagement '[Engagement Date])... The SELECTEDVALUE (' Engagement '[Engagement Date]) corresponds to the date selected by the slicer in the screenshot in my previous post. There is no slicer in your screenshot, which means no returned value. Hence there is no data display in the visual... In addition, I found there is one error about your formula. We need to count the number of meetings not the number of meeting type, so you need to update the formula from DISTINCTCOUNT('Engagement'[engagement_type]) to 'DISTINCTCOUNT('Engagement'[engagementid]) . Please complete the steps in below screenshot:

1. Add one slicer with Field "engagement_date"

2. Update the formula as below:

Ratio = var nm=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="MEETING"&&'Engagement'[engagement_date]=SELECTEDVALUE('Engagement'[engagement_date]))) 
var nc=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="CALL"&&'Engagement'[engagement_date]=SELECTEDVALUE('Engagement'[engagement_date])))
return DIVIDE(if(ISBLANK(nm),0,nm),if(ISBLANK(nc),1,nc))

divide2.JPG

The following documentations describe the details of these functions applied in the formula:

https://docs.microsoft.com/en-us/dax/distinctcount-function-dax

https://docs.microsoft.com/en-us/dax/selectedvalue-function

https://docs.microsoft.com/en-us/dax/filter-function-dax

https://docs.microsoft.com/en-us/dax/divide-function-dax

Best Regards

Rena

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.

Thank you so much @v-yiruan-msft , it worked 🙂 I had actually already added the slicer without success, but after correcting the code it went from blank to filled.

Is there a way I can look at ratio over time using this measure? It will only show the ratio for specific dates, not multiple dates (when I select multiple dates it returns 0). Ideally, I'd like to see how this ratio changes over time.

Hi @enorberg ,

Please try to update the formula as below:

Ratio = var nm=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="MEETING"&&'Engagement'[engagement_date] in VALUES('Engagement'[engagement_date]))) 
var nc=CALCULATE(DISTINCTCOUNT('Engagement'[engagementid]),FILTER(ALL('Engagement'),'Engagement'[engagement_type]="CALL"&&'Engagement'[engagement_date] in VALUES('Engagement'[engagement_date])))
return DIVIDE(if(ISBLANK(nm),0,nm),if(ISBLANK(nc),1,nc))

Best Regards

Rena

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.

Thank you @v-yiruan-msft, this really helped 🙂 Just to make sure I understand, this calculates the daily ratio, right? Not the accumulated ratio at any given day?

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.