Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.