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 of Certain Rows

First, I just want to say I'm new to Power BI and DAX for that matter. Below I've put a bit of sample data of what I'm trying to accomplish. I'm trying to sum the usage of a certain person on a given date (Total column is what I'm trying to accomplish).

Sample Data.png

But below is what I'm getting.

More Sample Data.png

The DAX formula that I'm using is: Total = CALCULATE(SUM('Table'[Usage]), DISTINCT('Table'[Date]), DISTINCT('Table'[Person]))

 

I've been trying to solve this for the last two days and can't figure out why it's not summing the way I want it to... Please help!!

2 ACCEPTED SOLUTIONS
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

Your DAX expression does indeed not lead to the expected results. The solution of @Tahreem24  is also not working, as you cannot use EARLIER() in a measure. However, you can use it in a Calculated Column.

Try the following DAX in a calculated column:

Total =
VAR currentRowDate = 'Table'[Date]
VAR currentPerson = 'Table'[Person]
RETURN
CALCULATE(SUM('Table'[Usage]), FILTER(Table, 'Table'[Date] = currentRowDate && 'Table'[Person] = currentPerson))

If you want to understand what this does, let me know! I wrote it out so it is the most readable for you 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





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

Proud to be a Super User!




View solution in original post

Create a measure like below :
Total = CALCULATE (SUM(Table[Usage]), Filter(Table, Table[Datecolumn]=Earlier(Table[Datecolumn ] )&&Table [Person] =Earlier (Table[Person])))

Please replace, with & &
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

8 REPLIES 8
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

Your DAX expression does indeed not lead to the expected results. The solution of @Tahreem24  is also not working, as you cannot use EARLIER() in a measure. However, you can use it in a Calculated Column.

Try the following DAX in a calculated column:

Total =
VAR currentRowDate = 'Table'[Date]
VAR currentPerson = 'Table'[Person]
RETURN
CALCULATE(SUM('Table'[Usage]), FILTER(Table, 'Table'[Date] = currentRowDate && 'Table'[Person] = currentPerson))

If you want to understand what this does, let me know! I wrote it out so it is the most readable for you 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





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

Proud to be a Super User!




Tahreem24
Super User
Super User

Create a measure like below :
Total = CALCULATE (SUM(Table[Usage]), Filter(Table, Table[Datecolumn]=Earlier(Table[Datecolumn ] ), Table [Person] =Earlier (Table[Person])))

Please give Kudos and accept this as a solution if it helps you.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Create a measure like below :
Total = CALCULATE (SUM(Table[Usage]), Filter(Table, Table[Datecolumn]=Earlier(Table[Datecolumn ] )&&Table [Person] =Earlier (Table[Person])))

Please replace, with & &
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Sorry for type.. Instead of measure create column and use formula which mentioned by me in previous post.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

 @Tahreem24 and @JarroVGIT these both work, thank you so much from keeping me from pulling my hair out!!

@Anonymous  I don't want to be a posterboy for bad sportmandship but @Tahreem24 solution cannot possible work as a measure. That would only work as a calculated column.

 

EDIT: Apologies @Tahreem24; just read your last post 🙂





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

Proud to be a Super User!




djerro123, if you read my latest post so I mentioned it was a typo mistake(mistype measure) . Else solution is workable for calculated column.
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Should there be a closed parenthesis after Earlier(Table[Datecolumn ] )? I keep on getting an error: Too many arguments were passed to the FILTER function. The maximum argument count for the function is 2.

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.