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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
gcv1999
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

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
v-eachen-msft
Community Support
Community Support

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.

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

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.
parry2k
Super User
Super User

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



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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.

@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 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.