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 all sales by ID if status has reached X

Guys, I need a measure. Hope someone can help 🙂  

I've got a question regarding how to sum all rows of a column by an ID based on the following requirement: 

- Only sum the points of IDs if that ID has one (or more) rows containing "some_text" in a third column (in my example the text "Finished").

 

Here's an example: 

table.jpg

 

In this example, the measure should return: 35 (since the sum of points of all IDs with one or more Status="Finished" is 35).

 

Thanks for answers. 

 
 

 

1 ACCEPTED SOLUTION

First create a table for finished status IDs:

Finished_Table = FILTER(Data, Data[Status]="Finished")

Then create a new column to calculate sum(points) of IDs in that table:

Sum_of_Finished = CALCULATE(SUM(Data[Points]), FILTER(Data, Data[ID] = Finished_Table[ID]))

 

View solution in original post

8 REPLIES 8
baghdadi62
Resolver III
Resolver III

If you have only one "Finished" in your table:

 

CALCULATE(SUM(Data[Points]), FILTER(Data, Data[ID] = LOOKUPVALUE(Data[ID], Data[Status], "Finished")))

 

 

Anonymous
Not applicable

Thanks for replying. 

To clarify, there are many "finished" in the column. It is a massive table with millions of rows. Would this still work?

No, becaues lookupvalue works only with one value to find.

Can we use new column before having measure or it is forcible to have a measure only?

Anonymous
Not applicable

It's connected through Direct Query, but I can have a calculated column in the Data-tab in my solution (thats no problem). 

First create a table for finished status IDs:

Finished_Table = FILTER(Data, Data[Status]="Finished")

Then create a new column to calculate sum(points) of IDs in that table:

Sum_of_Finished = CALCULATE(SUM(Data[Points]), FILTER(Data, Data[ID] = Finished_Table[ID]))

 

Anonymous
Not applicable

I feel confident this is the right solution, however I'm getting the error "exceeding max row limit of 1000000" 😕 
This is because I'm using Direct Query. 

I'll mark your solution as the right answer for the record, but if you have any suggestion on how I can make this solution work with the DQ limitations I'd be most grateful. 

 

Best. PJ

And a measure for show result in a Card:

Measure_3 = SUMX(ADDCOLUMNS(VALUES(Data[ID]), "x", CALCULATE(COUNTROWS(Data))),
            IF([x]=3, CALCULATE(SUM(Data[Points]))))

OK.

and here is a measure for you:

Measure_2 = 
Var x = countrows(Data)
return
if(x=3, sum(Data[Points]))

It can be used in a Matrix with IDs.

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.