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.
Hello,
I'm looking to summarize my data by getting monthly transaction sums (including the year as well, i.e. MM/YY) and filtering them by individual account numbers. Below is an example:
Date | Account Number | Transaction Amount | ||
1/20/2020 | 1 | 10 | ||
1/21/2020 | 1 | 30 | ||
2/4/2020 | 1 | 20 | ||
2/9/2020 | 1 | 10 | ||
2/15/2020 | 1 | 20 | ||
1/20/2020 | 2 | 30 | ||
1/21/2020 | 2 | 30 | ||
2/4/2020 | 2 | 10 | ||
2/9/2020 | 2 | 20 | ||
2/15/2020 | 2 | 10 | ||
2/20/2020 | 2 | 20 |
I want to take that and make it into this:
Transaction Month | Account Number | Monthly Sum | ||
Jan-20 | 1 | 40 | ||
Feb-20 | 1 | 50 | ||
Jan-20 | 2 | 60 | ||
Feb-20 | 2 | 60 |
I converted the dates to the format I want with this code:
Transaction Month = MONTH(Table[Date]) & "/" & YEAR(Table[Date])
Then got the total monthly sum:
Total Monthly Sum = CALCULATE(sum(Table[Transaction Amount]),ALLEXCEPT(Table, Table[Transaction Month]))
Hi @ amgt ,
Here are the steps you can follow:
Month = FORMAT('Table'[Date],"MMMM")
2. Create a Calculation Table.
Table 3 =
SUMMARIZE('Table','Table'[month],'Table'[Account Number],
"Transaction Month",SUM('Table'[Transaction Amount]))
3. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The trouble with your approach is it is one off - converting the dates to months. Power BI is designed to work with a star Schema. You should create and load a calendar table and an account table.
https://exceleratorbi.com.au/power-pivot-calendar-tables/
https://exceleratorbi.com.au/the-optimal-shape-for-power-pivot-data/
Thanks for the reply. Any insight into how to apply a calendar and account table so that I can create a calculated column for the monthly sum by account number? The end goal is to identify monthly account spend that exceeds individual account monthly spending limits.
You can use Power Query to create a calendar table.
https://exceleratorbi.com.au/build-reusable-calendar-table-power-query/
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |