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
WorkHard
Helper V
Helper V

When calculating the total events per month, only count the event in the starting month

Trying to understand the following behavior.

 

Say I have 2 events and on average each event lasts at least 2 months.

 

Event IDStart DateEnd Date
11/1/20203/1/2020
24/1/20206/1/2020

 

When I create a very simple chart and display the total events per month (event id distinct count), the same event appears in 3 different months and gives the illusion that I have more events than there actually are.

 

I have a calendar linked to start date.

 

How can I only display the event in the month it started?

 

1 ACCEPTED SOLUTION

Hi @WorkHard ,

 

You can try to create a measure to distinctcount the event id:

 

Measure = var min_date = CALCULATE(MIN(Event[Start Date]),ALLEXCEPT(Event,Event[Event ID]))
var distinct_ =  CALCULATE(DISTINCTCOUNT(Event[Event ID]),FILTER(Event,Event[Start Date]=min_date))
return SUMX(VALUES(Event[Event ID]),distinct_)

 

V-lianl-msft_0-1605681370993.png

 

 

Best Regards,
Liang
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

3 REPLIES 3
mahoneypat
Employee
Employee

The behavior you are looking for is the default behavior if there is a relationship between the Date table and the Start Date column.  Please make sure:

1. That relationship is active

2. The columns on both sides of the relationship are the same data type (Date not DateTime for example)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks, Pat.

 

1. Yes, the relationship between the Start Date and the date in the calendar table is active. 

2. Yes, both columns are the same data type (both are date/time).

 

What else could it be?

To clarify, the Grand Total is displayed correctly as 2 events but the breakdown by month still shows 6 (1 event for each month).

 

WorkHard_0-1605157553721.png

 

Hi @WorkHard ,

 

You can try to create a measure to distinctcount the event id:

 

Measure = var min_date = CALCULATE(MIN(Event[Start Date]),ALLEXCEPT(Event,Event[Event ID]))
var distinct_ =  CALCULATE(DISTINCTCOUNT(Event[Event ID]),FILTER(Event,Event[Start Date]=min_date))
return SUMX(VALUES(Event[Event ID]),distinct_)

 

V-lianl-msft_0-1605681370993.png

 

 

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

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.