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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Filtered Count Including Previous Transactions but Excluding Future Transactions

The goal is to count transactions that were previously done but exclude any for the future. Ex: Count all transactions that happened in January 2023 but for February 2023 (and beyond), only Pizza transactions. I was successful in creating a filter that will only count Pizza transactions but I am confused on how I can get the January 2023 Sushi transaction to be counted (excluding Sushi February 2023 transactions and beyond). Below you will find sample data and expected output for context. 

 

Your support is greatly appreciated. 

 

Sample DAX Measure: I am aware that this filters out all Sushi transactions but confused on how to include just January 2023 and exclude any after

 

 

CALCULATE(
    COUNT( trans_id )
    ,FILTER(
        transactions
        ,transactions.product_code <> '200'
    )
)

 

 

 

Sample Data

trans_id product_code product date
1 100 Cheese Pizza 1-Jan-23
2 100 Cheese Pizza 2-Jan-23
3 200 Sushi 2-Jan-23
4 300 Pineapple Pizza 30-Jan-23
5 200 Sushi 3-Feb-23
6 100 Cheese Pizza 9-Feb-23
7 200 Sushi 20-Feb-23
8 300 Pineapple Pizza 22-Feb-23
9 300 Pineapple Pizza 25-Feb-23
10 200 Sushi 28-Feb-23

Expected Output: Notice that January 2023 Sushi transaction was counted but excluded from February 2023

product_code product month_year transaction_count
100 Cheese Pizza Jan-23 2
200 Sushi Jan-23 1
300 Pineapple Pizza Jan-23 1
100 Cheese Pizza Feb-23 1
300 Pineapple Pizza Feb-23 2

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@parry2k thank you so much for your support but I was able to rework some other measures and filters within my project to provide the expected output. Regarding your question, for this specific example...yes this logic is only applying towards "Sushi". But my true application will be filtering a few dozen more items. 

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous You marked this post as solved, I guess you already have the solution, correct? From your last reply, it was not clear if you need further help or if you are good to go. 🤷‍♂️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous one thing is not clear, is this logic only applied to sushi?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k thank you so much for your support but I was able to rework some other measures and filters within my project to provide the expected output. Regarding your question, for this specific example...yes this logic is only applying towards "Sushi". But my true application will be filtering a few dozen more items. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.