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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.