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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
win_anthony
Resolver III
Resolver III

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

@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

@win_anthony 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

@win_anthony 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.

@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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.