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
ssbagley
Helper III
Helper III

Subtotal of Amount by Person

I've been researching this all day and have had no luck.

 

I am dealing with employee expenses and I am connected via Direct Query.  I need to identify every employee with total expenses over $800 which means my measure needs to be able to filtered to > $800.  Everything I have tried only gives me individual transactions over $800, but I need the total by person that is over $800.  

 

Thoughts? 

Data Table:

Emp IDDateAmount
11/2/2023 $  500.00
22/4/2023 $  875.00
32/5/2023 $  810.00
33/1/2023 $  100.00
41/17/2023 $  715.00
51/20/2023 $  972.00
62/7/2023 $  300.00
62/8/2023 $  550.00


Desired Result:

Apply filter (to visual or not): Amt per person > $800.00

Emp IDAmount
2$875
3$910
5$972
6$850

 

 

 

 

 

4 ACCEPTED SOLUTIONS
Padycosmos
Solution Sage
Solution Sage

Hope this helps:

Padycosmos_0-1678314580608.png

 

View solution in original post

Thank you it makes it now more easier than 1000 words. 🙂
Please try this. The filter calculated it in the group of the Employee No.:

andhiii079845_0-1678391702334.png
Filter = 
VAR _t = CALCULATE(sum(Expenses[Amount]),ALLEXCEPT(Expenses,Expenses[Emp No]))
Return _t
You can it change it easy to a Filter for the filter pane:
Filter = 
VAR _t = CALCULATE(sum(Expenses[Amount]),ALLEXCEPT(Expenses,Expenses[Emp No]))
RETURN IF(_t>800,1,0)
 You can than choose "equal or greater than" 1.
 
Did it help?




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

Proud to be a Super User!




View solution in original post

My fault by copying:

Filter = 
VAR _t = CALCULATE(sum(Expenses[Amount]),ALLEXCEPT(Expenses,Expenses[Emp No]))
RETURN IF(_t>800,1,0)




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

Proud to be a Super User!




View solution in original post

bolfri
Super User
Super User

Total Exp:

Total Exp = 
var emp = VALUES(Expenses[Emp No])
return
SUMX(
    SUMMARIZE(
        FILTER(ALLSELECTED(Expenses),Expenses[Emp No] in emp),
        Expenses[Emp No],
        "Total",SUM(Expenses[Amount])
    ),
    [Total]
)

 

Result:
You can put it on visual level to work on aggregated items.

bolfri_0-1678393101033.png

Or add more columns to see details.

bolfri_1-1678393157439.png

 





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

Proud to be a Super User!




View solution in original post

29 REPLIES 29
bolfri
Super User
Super User

Total Exp:

Total Exp = 
var emp = VALUES(Expenses[Emp No])
return
SUMX(
    SUMMARIZE(
        FILTER(ALLSELECTED(Expenses),Expenses[Emp No] in emp),
        Expenses[Emp No],
        "Total",SUM(Expenses[Amount])
    ),
    [Total]
)

 

Result:
You can put it on visual level to work on aggregated items.

bolfri_0-1678393101033.png

Or add more columns to see details.

bolfri_1-1678393157439.png

 





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

Proud to be a Super User!




Thank you!  This also worked for me (for all the future people searching for answers!)

andhiii079845
Super User
Super User

Make a example (sample data) how this related tables are in connection with the main table (amount) and i can check it to find a general and flexible solution. 





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

Proud to be a Super User!




Sample data: https://drive.google.com/file/d/1vyqpCH07sEYeOhGRnHdy9qA5RaIDvGtv/view?usp=share_link
(Now I cannot get your measure to work at all - 😩 )

Thank you it makes it now more easier than 1000 words. 🙂
Please try this. The filter calculated it in the group of the Employee No.:

andhiii079845_0-1678391702334.png
Filter = 
VAR _t = CALCULATE(sum(Expenses[Amount]),ALLEXCEPT(Expenses,Expenses[Emp No]))
Return _t
You can it change it easy to a Filter for the filter pane:
Filter = 
VAR _t = CALCULATE(sum(Expenses[Amount]),ALLEXCEPT(Expenses,Expenses[Emp No]))
RETURN IF(_t>800,1,0)
 You can than choose "equal or greater than" 1.
 
Did it help?




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

Proud to be a Super User!




Trying it all now.  The first one works beautifully (like, literally excited about it!!!).  The second, I'm getting "The syntax for 'IF' is in correct." 

 

I cannot thank you enough!!

My fault by copying:

Filter = 
VAR _t = CALCULATE(sum(Expenses[Amount]),ALLEXCEPT(Expenses,Expenses[Emp No]))
RETURN IF(_t>800,1,0)




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

Proud to be a Super User!




Any idea why the measure above would stop working? When I try to add as a filter now, my table visual errors out. 

Thank you‼️‼️‼️

 

Please set @Padycosmos post also as a solution, I see he mentioned it some days before 🙂





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

Proud to be a Super User!




Padycosmos
Solution Sage
Solution Sage

Hope this helps:

Padycosmos_0-1678314580608.png

 

Thank you for your reply!  This gave me the same total on every line. ☹️

ssbagley
Helper III
Helper III

Using a matrix, if I only have Emp ID and Name in the Rows and (Sum of)"Amount" in the values, then the measure works like a charm.  But, if I add date or any other details, it limits the "Transaction Amount" to $800+.  I have one person that has 28 expenses that make up a total of $2,225.03, but if I try to get to the detail, I can't.

YukiK
Impactful Individual
Impactful Individual

Do you need a table like that or need a visual showing filtered employees?

 

Regardless, you can do the followings.

 

1. Filter in a visual

YukiK_0-1678218168264.png

 

2. Filtered employees table

Filtered Emplpoyees = 
FILTER( 
    SUMMARIZE(
        'Table',
        'Table'[Emp ID]
    ),
    [Employee Total Expenses] >= 800
)

 

Thank you for your response.  When I add the Total to a visual filter, it just gives me the individual submisions made for $800+, not the total.

I tried the table but clearly do not have it set up correctly - would this measure be added as a filter or a column in a Matrix?  Sorry - trying to determine how to use.

YukiK
Impactful Individual
Impactful Individual

1. Build the measure in my screenshot I attached previously

2. Bring in EmpID into a table/matrix visual

3. Bring in the measure into the visual

4. The filter on that measure has been added to the visual

5. Filter greater than 800 in the filter

 

Does this help...?

I am trying to get this to work. Direct Query with a TON of data - trying to filter it down so it will refresh in a timely manner at least for testing purposes. 

andhiii079845
Super User
Super User

Try this: You have to change the table name.

measure =
Var _t = SUMMARIZE(ppl,ppl[Emp ID],"_sum",sum(ppl[Amount]))
RETURN sumx(FILTER(_t,[_sum]>800),[_sum])
andhiii079845_0-1678217799444.png

 

Make the post as a solution if it was helpfull.





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

Proud to be a Super User!




Thiis works, until I try to add a filter to remove the blanks (ie. employees whose expenses are not >$800).  I will keep playing with it though.  Thank you for your reply!

let us know if you need more help. mark a or two post as solution. 🙂





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

Proud to be a Super User!




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.