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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors