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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Microsoft Employee
Microsoft 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors