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
Anonymous
Not applicable

Sum per Month per Location

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:

 

TotalDateLocationTotalPerMonthPerLocation
1501-01-18A25
1002-01-18A25
501-01-18B15
1002-01-18B15
1501-02-18A20
502-02-18A20
2001-02-18B35
1502-02-18B35

 

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:

 

TotalDateLocationTotalPerMonthPerLocation
1501-01-18A40
1002-01-18A40
501-01-18B40
1002-01-18B40
1501-02-18A55
502-02-18A55
2001-02-18B55
1502-02-18B55

 

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 ❤️

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
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])))

image.png





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

Proud to be a PBI Community Champion




View solution in original post

2 REPLIES 2
PattemManohar
Community Champion
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])))

image.png





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

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar 

 

That worked!

 

Thank you a lot for your help!

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.