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
Huskyjimbo
Frequent Visitor

New Customers who had specific repair done within a year

I'm trying to get a percentage of new customers (since 2018) in the state of Maryland who subsequently had engine service done at one of our service centers within a year.  We also send out to a more advanced engine repair shop, and I don't want those customers counted as having engine service done.  

 

I have a "new customer" service type for their first appt. and a service type of   "Engine Repair In-house" for the repair.  

 

 

So i basically want

 

measure 1

Total New Customers since 2018 in Maryland = CALCULATE(distinctcount('DIM_Customers'[Customer_Nbr]), filter('DIM_Location', 'DIM_Location'[Location_State_Cd]="MD"),'DIM_Service', 'DIM_Service'[Service_Type]="New Customer")

 

Measure 2

Count of the customers in Measure one who had engine repair done at one of our service centers within a year of their first visit:

 

????

 

Final calc= measure 2/Measure 1

 

Any help with measure 2 would be huge.

 

Thanks,

Jim

1 ACCEPTED SOLUTION

Hi @Huskyjimbo ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1600762635085.png

 

Best regards,
Lionel Chen

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

6 REPLIES 6
amitchandak
Super User
Super User

@Huskyjimbo ,

We need to have date New Customer and then we will use 12 month from there. You can calculate that as column too

CALCULATE(

distinctcount('DIM_Customers'[Customer_Nbr]), filter('DIM_Location', 'DIM_Location'[Location_State_Cd]="MD"),filter('DIM_Service', 'DIM_Service'[Service_Type]="Engine Repair In-house"),DATESINPERIOD('Date'[Date ],MIN(DIM_Service[DIM_Service Date]),12,MONTH))

 

Can you share sample data and sample output in a table format? Or a sample pbix after removing sensitive data.

 

refer how min date is calculated as column

https://youtu.be/Q1vPWmfI25o?t=751

Hi @Huskyjimbo ,

 

Please refer to this.

If this is not what you want, please give the return value of [Measure2].

Within a year = 
VAR __min_date  = 
MINX(
    FILTER( ALL(Fact_Service), Fact_Service[Customer_key] = MAX(Fact_Service[Customer_key]) ),
    [Service_Date]
)
VAR __max_date  = 
MAXX(
    FILTER( ALL(Fact_Service), Fact_Service[Customer_key] = MAX(Fact_Service[Customer_key]) ),
    [Service_Date]
)
RETURN
DATEDIFF( __min_date, __max_date, DAY )
Measure = 
CALCULATE(
    DISTINCTCOUNT(Fact_Service[Customer_key]),
    FILTER(
        Fact_Service,
        [Within a year] <= 365  && Fact_Service[Service_Type_Key] = 7
    )
)

v-lionel-msft_0-1599715099209.png

 

Best regards,
Lionel Chen

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

 

 

Here is what i am trying to achieve, 33%.  So i need a temporary list of new customers since 2018 in Maryland.  Then using this temp list and the criteria, "in house engine repair within a year", i would get a count of how many achieved that criteria which is 1 of the 3 new customers since 2018 in Maryland.

 

engine example.JPG

Hi @Huskyjimbo ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1600762635085.png

 

Best regards,
Lionel Chen

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

 

Greg_Deckler
Super User
Super User

@Huskyjimbo This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.