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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
refint650
Helper III
Helper III

Group by & Count of employee

Hi ALL.

 

i'm doing measure calculation with custom group of columns for sales amount and purchase amount from single table

1st variable does calculate sum of salesamount for 5 of columns.

2nd variable does calculate sum of purchase amont for same 5  columns.

 3rd variable does %margin calculation (sales/profit). 

 

now my requirement i want distinct count of employees with margin % between >5% and <90%  from the above groupby column combination only because of data structures. so can i same filter condition in same variance measure.?

 

 

Variance = 

VAR _sales = GROUPBY(TableX, State, City, Product, EmployeeID, Date,"Sales", SUMX(CURRENTGROUP(), [SalesAmount))

VAR _Profit = GROUPBY(TableX, State, City, Product, EmployeeID, Date,"Purchase", SUMX(CURRENTGROUP(), [PurchaseAmount))

Var _Margin  =Divide( CALCULATE(SUMX(_Sales,[SalesAmount]),ALLEXCEPT(TableX, [DATE])) , CALCULATE(SUMX(_Profit,[PurchaseAmount]),ALLEXCEPT(TableX,[DATE])))
return _Margin.

I tried doing new calcuation  on  top of [Variance] Measure didnt work well either some ws are missing  data is not accurate or outer filters not applying within measure scondition,Much appreciated for help 🙂

 

file attachment

https://www.dropbox.com/scl/fi/fkj67r7t8iyzz8q58xfs0/Thresholddata.xls?dl=0&rlkey=aa6zbwd3xhwccvkucf...

 

 

IF ( [Variance] < 90 ,CALCULATE ( DISTINCTCOUNT ( TableX[EmployeeID]), FILTER ( ALL ( 'TableX' ), [Variance] < 1 )),0 )

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Going by your description, this measure should work

=countrows(filter(values(TableX[EmployeeID]),[Margin]>0.05&&[Margin]<0.90))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Going by your description, this measure should work

=countrows(filter(values(TableX[EmployeeID]),[Margin]>0.05&&[Margin]<0.90))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

expression worked for 85% of data. but i figured we have to apply filter expression on both variable sales & purchase after group by condition to drop rows with 0 amount values. then your provided filter should work 100%

You marked my response as Answer.  So has my formulas resolved your problem?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.