Forum Discussion
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 |
- Anonymous3 years ago
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.
3 Replies
- parry2kSuper User
Anonymous one thing is not clear, is this logic only applied to sushi?
- AnonymousNot 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.
- parry2kSuper 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. 🤷♂️