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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.