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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
rgblaze21
New Member

Dynamic Group By transactions within the past 1 year

The objective is to determine whether a customer's total transaction balance has reached the maximum threshold for the past year (365) days every time the customer transacts.

 

For example, Customer A has a transaction on July 1, 2023 for a total of $100. I need to check Customer A's total transaction amount from July 1, 2022 to June 30, 2023 (or within 1 year prior to July 1, 2023). This checking would be done whenever he has a transaction.

 

Currently, I have a single dataset of historical orders for all customers for the past 2 years containing the following fields (Customer, Transaction Date, Amount). 

 

My idea is for every customer transaction record, I must have another column that will show the total balance of that customer for the past 365 days. Like this:

 

CustomerTransaction DateAmount

Customer's Total Amount 

(for the past 365 days prior to Transaction Date)

AJuly 1, 2023100<Total Sum of Customer A's transactions filtered from July 1, 2022 to June 30, 2023>
BJuly 3, 2023150<Total Sum of Customer B's transactions filtered from July 3, 2022 to July 2, 2023>

 

Any idea on how to go about it in Power Query? Thanks a lot!

2 REPLIES 2
j_ocean
Helper V
Helper V

"This checking would be done whenever he has a transaction."

 

Is PBI where you want to be doing this check? It sounds like something that should be further upstream before the transaction is authorized.

 

But anyway this can be done in Power Query by referencing the table, adding a column with todays date -365 days, a logic column to filter out older stuff, and a group-by. Link it by customer ID to the main table. Depending on how you do it you now have a way to display the last refresh date and a "transactions since..." date in your report.

wdx223_Daniel
Super User
Super User

Power Query is not good at this job to group data dynamicly.

suggest to do it with DAX

Measure=VAR _d=MAX(Table[Transaction Date]) RETURN CALCULATE(SUM(Table[Amount]),Table[Transaction Date]<_d&&DATEDIF(Table[Transaction Date],_d,YEAR)<1)

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.