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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
paulsnet1986
Helper I
Helper I

Count Number of Transactions If Date Range Fell Within Calendar Month

I have two tables: a table with customers active in a calendar month and a table of transactions with start and end dates. I want to make a Power BI table that lists the customers and, when filtered by a calendar month, counts the number of transactions that were running during any part of the calendar month. I cannot think of how to do this because I need to link the tables by both customer number and dates? Any help would be appreciated!

 

Table 1

paulsnet1986_0-1696524481581.png   

Table Two

paulsnet1986_1-1696524512950.png

 

Desired Output

paulsnet1986_2-1696524592118.png

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @paulsnet1986 

 

You can try the following methods.
Measure:

Count = 
VAR _selectedmonth = MONTH ( SELECTEDVALUE ( Table1[Calender Month] ) )
VAR _Count1 = CALCULATE ( COUNT ( Table2[Transaction] ), FILTER ( ALL ( Table2 ),
            MONTH ( [Start Date] ) <= _selectedmonth && [End Date] = BLANK ()
                && [Customer] = SELECTEDVALUE ( Table1[Active Customers] ) ) )
VAR _Count2 = CALCULATE ( COUNT ( Table2[Transaction] ), FILTER ( ALL ( Table2 ),
            MONTH ( [Start Date] ) <= _selectedmonth && MONTH ( [End Date] ) >= _selectedmonth
                && [Customer] = SELECTEDVALUE ( Table1[Active Customers] ) ) )
RETURN
    _Count1 + _Count2 + 0

vzhangti_0-1696924140092.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @paulsnet1986 

 

You can try the following methods.
Measure:

Count = 
VAR _selectedmonth = MONTH ( SELECTEDVALUE ( Table1[Calender Month] ) )
VAR _Count1 = CALCULATE ( COUNT ( Table2[Transaction] ), FILTER ( ALL ( Table2 ),
            MONTH ( [Start Date] ) <= _selectedmonth && [End Date] = BLANK ()
                && [Customer] = SELECTEDVALUE ( Table1[Active Customers] ) ) )
VAR _Count2 = CALCULATE ( COUNT ( Table2[Transaction] ), FILTER ( ALL ( Table2 ),
            MONTH ( [Start Date] ) <= _selectedmonth && MONTH ( [End Date] ) >= _selectedmonth
                && [Customer] = SELECTEDVALUE ( Table1[Active Customers] ) ) )
RETURN
    _Count1 + _Count2 + 0

vzhangti_0-1696924140092.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

 

vanessafvg
Super User
Super User

please provide data in text format.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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