cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HugoC
Regular Visitor

Count number of cases per customer per month based on contract date in customer table

Hello,

My case should be simple enough for the experts out there. I'm eagher to become one! 🙂

I have 3 tables:
- Cases table with opened_at, Customer name, case number
- Customer Info table with Customer name, start date, Last Cycle Date and other date columns

- Calendar table

I have relationships between:

- Case table and Calendar table (Calendar.Date --> Case.opened_at)

- Case table and Customer table ( Customer Info.Customer <--> Case.CustomerName)

 

I need to create a visual that returns the count of cases a customer opened after Last Cycle Date that is stored in the Customer Info table.

The best I achieved was to create a measure that returns correct number of cases after Last Cycle Date (which is 23/03/2023) but also returns a weird count prior to Last Cycle Date.

#OrdersPerStartDate =
CALCULATE(
    COUNTROWS('Cases'),
    USERELATIONSHIP('Calendar'[Date],'Cases'[opened_at]),
    FILTER(
        ALL('customer info'),
         'customer info'[Last Cycle Date] <= MAX('Calendar'[Date]) &&
         'customer info'[Customer] = SELECTEDVALUE('customer info'[Customer])
    )
)
HugoC_0-1685551943366.png

 

What I expect is to have results only for last 3 rows in this customers example since the Last Cycle Date is 23/03/2023.
Your help is much appreciated 

 

Hugo

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @HugoC ,

 

I can't tell the difference between the correct value and the wrong value just by looking at the picture. What do they look like in the original data?

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors
Top Kudoed Authors