cancel
Showing results for
Did you mean:
Highlighted
Helper I

## Sum and Total IDs up to a given goal

Hello Everyone,

I have two tables that look as so:

So each taskID has a goal, for instance the taskID ending in 9910 has a goal of 8. However, if I count the number of ids assigned to the taskID 9910 it is 12, but the goal is 8. I'd like to create a measure that counts the ids assigned to a taskID UP TO the respective goal for each taskID. Then I'd like to add up all of the ones that are assigned and compare it to the total goal of 34 in this case.

For instance, there could be 80 ids in total assigned to the taskIDs which have a total goal or limit of 34. However, if for a certain taskID there are 5 assigned when the goal is 6, then the cumulative assigned is 33, not 79. Basically, the cumulative total of ids assigned should not be higher than set goal (34 in this case), and each taskID is has a separate goal (8 in this case).

Thank you, and let me know if this post needs further clarification.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support

## Re: Sum and Total IDs up to a given goal

Hi @gcv1999 ,

You could refer to the following measures. "Table1" is your fact table, "Table2" is your goal table.

``````count =
VAR a =
DISTINCTCOUNT ( 'Table1'[id] )
VAR b =
LOOKUPVALUE (
'Table2'[goal],
)
RETURN
IF ( a >= b, b, a )``````
``````sum =
SUMX ('Table2', [count] )``````

Here is the result.

If this post helps, then please consider Accept it as the solution to help the other members find it.
5 REPLIES 5
Highlighted
Super User IV

## Re: Sum and Total IDs up to a given goal

@gcv1999 I would recommend to put a sample excel file with sample data and calculations, it will help a lot.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Highlighted
Helper I

## Re: Sum and Total IDs up to a given goal

@parry2k I am working with a database directly, but I tried to put the data into a google doc for you to view. Hopefully this makes things clearer: Spreadsheet Link

Highlighted
Community Support

## Re: Sum and Total IDs up to a given goal

Hi @gcv1999 ,

Refer to the following measures.

``````count =
DISTINCTCOUNT('Table'[id])``````
``````sum =
SUMX ( ALLEXCEPT ( 'Table', 'Table'[taskID] ), [count] )``````

Here is the result, but it is different with your online tables.

If this post helps, then please consider Accept it as the solution to help the other members find it.
Highlighted
Helper I

## Re: Sum and Total IDs up to a given goal

@v-eachen-msft I understand the formulas that you used, but what I am trying to do is compare the total number of taskIDs to the goal of each taskID. For instance, the 12 you got from totaling the taskID 9910 should be compared to its respective taskID in the second table. In this case the 12 should be compared to the 8, and since it is equal to or greater than 8, it should return 8. I am trying to find a measure that will do this for each taskID, so that the total is less than or equal to the total goal of 34.

Highlighted
Community Support

## Re: Sum and Total IDs up to a given goal

Hi @gcv1999 ,

You could refer to the following measures. "Table1" is your fact table, "Table2" is your goal table.

``````count =
VAR a =
DISTINCTCOUNT ( 'Table1'[id] )
VAR b =
LOOKUPVALUE (
'Table2'[goal],
)
RETURN
IF ( a >= b, b, a )``````
``````sum =
SUMX ('Table2', [count] )``````

Here is the result.

If this post helps, then please consider Accept it as the solution to help the other members find it.

Announcements

#### Power Platform Community Conference

Check out the on demand sessions that are available now!

#### Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

#### Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021