cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Sum and Total IDs up to a given goal

Hello Everyone,

 

I have two tables that look as so:

assigned.png

 

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

Here is the result.

1-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

5 REPLIES 5
Highlighted
Super User IV
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.






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

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





Highlighted
Helper I
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 

 

Community Support
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.

2-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Highlighted
Helper I
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
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],
        'Table2'[taskID], SELECTEDVALUE ( 'Table1'[taskID] )
    )
RETURN
    IF ( a >= b, b, a )
sum = 
SUMX ('Table2', [count] )

Here is the result.

1-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors