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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
villa1980
Resolver I
Resolver I

Count based on 2 filters then Divide by another measure

I would like to create a measure that counts the number of appointments, based on 2 filters for current month. How do I do this?
I have another measure that counts the number of sales id for current month. 
What I would then like to do is divide the 2 counts to return a percentage.

My filters are below

Current_Date = TODAY()-1
CM_Filter = IF('EXTR_STG_FOCUS APPOINTMENTS'[CM_TY] = 'EXTR_STG_FOCUS APPOINTMENTS'[Mth_SD], 1, 0)
CM_TD_Filter = IF('EXTR_STG_FOCUS APPOINTMENTS'[Current_Date] >= 'EXTR_STG_FOCUS APPOINTMENTS'[STARTDATE], 1, 0)
Current_Month = If ( Month(TODAY()-1)&YEAR(TODAY()-1) = MONTH('ODS SDW_SALE_TRANSACTION'[TRANSACTION_DATE])&YEAR('ODS SDW_SALE_TRANSACTION'[TRANSACTION_DATE]),1,0)

 

CM_App_Count = IF('EXTR_STG_FOCUS APPOINTMENTS'[CM_Filter] = 1 && 'EXTR_STG_FOCUS APPOINTMENTS'[CM_TD_Filter] = 1, count('EXTR_STG_FOCUS APPOINTMENTS'[APPOINTMENTID]),0)
 
CM_Sales_Id = IF ( 'ODS SDW_SALE_TRANSACTION'[Current_Month] = 1, count('EXTR_STG_FOCUS APPOINTMENTS'[SALEID]),0)
 
Thanks



1 ACCEPTED SOLUTION
villa1980
Resolver I
Resolver I

All Sorted, used distinct count in my calculations for both Sale Id and Appointment ID and boom 🙂

 

Count_Appts = CALCULATE(
    DISTINCTCOUNTNOBLANK('EXTR_STG_FOCUS APPOINTMENTS'[APPOINTMENTID]),
    FILTER('EXTR_STG_FOCUS APPOINTMENTS','EXTR_STG_FOCUS APPOINTMENTS'[CM_Filter] = 1 && 'EXTR_STG_FOCUS APPOINTMENTS'[CM_TD_Filter] = 1))

View solution in original post

1 REPLY 1
villa1980
Resolver I
Resolver I

All Sorted, used distinct count in my calculations for both Sale Id and Appointment ID and boom 🙂

 

Count_Appts = CALCULATE(
    DISTINCTCOUNTNOBLANK('EXTR_STG_FOCUS APPOINTMENTS'[APPOINTMENTID]),
    FILTER('EXTR_STG_FOCUS APPOINTMENTS','EXTR_STG_FOCUS APPOINTMENTS'[CM_Filter] = 1 && 'EXTR_STG_FOCUS APPOINTMENTS'[CM_TD_Filter] = 1))

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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