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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
OEUSOC
Frequent Visitor

Count times product was purchased over last 5 years based off individual transaction.

Hello,

 

I have a slicer setup to show transactions over the last one calendar week.

This works great to show the product that was purchased on that transaction.

However, I would also like a visual to show how many times that product was purchased over the last 5 years.

Any help is greatly appreciated.

PowerBI.jpg

6 REPLIES 6
OEUSOC
Frequent Visitor

It's a single table with 'Transaction#' as the unique identifier. I'm using a on the slicer that shows relative date, last one calendar week. I coped a column for 'TransactionDateTime' and transformed it to date only which is what you see in the screenshot above (and what I am also using in the slicer filter) . I want to display some specific transaction data along with some weekly data which I have been able to do. The last thing I need to do is show how many times that product has been purchased over the last 5 years.

@OEUSOC 

Try this measure in a card visual

Measure =
VAR baseDate_ = [TransactionDate] //The measure you already have and show in the card visual
VAR startOfPeriod_ =
    EDATE ( baseDate_, -5 )
VAR product_ = [Product] //The measure you already have and show in the card visual at the top
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Table1[Transaction#] ),
        FILTER ( ALL ( DateT ), DateT[Date] >= startOfPeriod_ )
    )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

@OEUSOC 

I wasn't notified of your last response. Seems to be a problem with the notifications.

[Product] = SELECTEDVALUE( Table1[ProductID] )
[TransactionDate] = SELECTEDVALUE( Table1[TransactionDate] )

If you share the pbix it would be easier to come up with a more accurate solution

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

OEUSOC
Frequent Visitor

Thanks AIB.

I do not have 'TransactionDate' and 'Product' setup as measures. They're simply fields from the table.

I wouldn't even begin to know how to make those measures in this case. Maybe I'm biting off more than I can chew right now.

Hi @OEUSOC ,

 

If possible,could you pls upload your .pbix file to onedrive business and share the link with us?

Remember to remove the confidential information.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

AlB
Super User
Super User

Hi @OEUSOC 

What field(s) define how many times a product was purchased? Waht are you using to specify the week, a slicer of a field of a date table? It would help if you show a sample of the relevant tables

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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