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 fellow forum friends,
I am a noob at DAX and PowerBI and I'm trying to solve the following problem:
Table1 has the following columns: Date, Total, and Location.
I have many entries per day and location.
I want to add an extra column called 'Total per month per location', that would add an entry with the sum of the values in Total for that month on that location.
Would look like this:
Total | Date | Location | TotalPerMonthPerLocation |
15 | 01-01-18 | A | 25 |
10 | 02-01-18 | A | 25 |
5 | 01-01-18 | B | 15 |
10 | 02-01-18 | B | 15 |
15 | 01-02-18 | A | 20 |
5 | 02-02-18 | A | 20 |
20 | 01-02-18 | B | 35 |
15 | 02-02-18 | B | 35 |
Right now I managed to have a column that shows the sum of Total on that month, but I also want it to discriminate it via Location.
Right now I have this:
Total | Date | Location | TotalPerMonthPerLocation |
15 | 01-01-18 | A | 40 |
10 | 02-01-18 | A | 40 |
5 | 01-01-18 | B | 40 |
10 | 02-01-18 | B | 40 |
15 | 01-02-18 | A | 55 |
5 | 02-02-18 | A | 55 |
20 | 01-02-18 | B | 55 |
15 | 02-02-18 | B | 55 |
My current query is
TotalPerMonth = CALCULATE(SUM(Table1[Total]),FILTER(Table1,Table1[Date]= EARLIER(Table1[Date])))
Can anyone help me alter the query so I can achieve what I'm trying to do?
Thank you ❤️
Solved! Go to Solution.
@Anonymous Please try this as a new column
TotalPerMonthPerLocation = CALCULATE(SUM(Test192LkpSum[Total]),FILTER(Test192LkpSum, MONTH(Test192LkpSum[Date]) = MONTH(EARLIER(Test192LkpSum[Date])) && Test192LkpSum[Location] = EARLIER(Test192LkpSum[Location])))
Proud to be a PBI Community Champion
@Anonymous Please try this as a new column
TotalPerMonthPerLocation = CALCULATE(SUM(Test192LkpSum[Total]),FILTER(Test192LkpSum, MONTH(Test192LkpSum[Date]) = MONTH(EARLIER(Test192LkpSum[Date])) && Test192LkpSum[Location] = EARLIER(Test192LkpSum[Location])))
Proud to be a PBI Community Champion
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |