Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Microsoft Power BI Community
- Forums
- Get Help with Power BI
- Desktop
- Re: Sum and Total IDs up to a given goal

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

gcv1999

Helper I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-16-2020
01:26 PM

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.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

v-eachen-msft

Community Support

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-17-2020
06:47 PM

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],
'Table2'[taskID], SELECTEDVALUE ( 'Table1'[taskID] )
)
RETURN
IF ( a >= b, b, a )
```

```
sum =
SUMX ('Table2', [count] )
```

Here is the result.

Community Support Team _ Eads

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

If this post

5 REPLIES 5

Highlighted
##

parry2k

Super User VII

Re: Sum and Total IDs up to a given goal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-16-2020
01:44 PM

Highlighted
##

gcv1999

Helper I

Re: Sum and Total IDs up to a given goal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-16-2020
03:01 PM

@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
##

v-eachen-msft

Community Support

Re: Sum and Total IDs up to a given goal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-17-2020
01:05 AM

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.

Community Support Team _ Eads

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

If this post

Highlighted
##

gcv1999

Helper I

Re: Sum and Total IDs up to a given goal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-17-2020
08:55 AM

@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

v-eachen-msft

Community Support

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-17-2020
06:47 PM

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],
'Table2'[taskID], SELECTEDVALUE ( 'Table1'[taskID] )
)
RETURN
IF ( a >= b, b, a )
```

```
sum =
SUMX ('Table2', [count] )
```

Here is the result.

Community Support Team _ Eads

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

If this post