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

Need help in calcualting the avg distinct values

Hi friends,
I have 3 tables including order, salesman and product like blow:

OrderCodeSalesManCodeProductcodeOrderDateQuantityAmount
10222710112/12/201612240
10222811212/12/201622343
1022255312/12/201614223
1022304112/12/201621221
10220711212/12/201644332
10222114412/12/201622453
10225211513/12/201611256
10220616513/12/201613431
1022447113/12/201656316
10221419213/12/201661395
10220616313/12/201625293
1022061713/12/201614413
10225117813/12/201656267
1022374613/12/201630333
10220819413/12/201647277
102248141013/12/201626374
10225517414/12/201639316
10221511314/12/201629296
1022322914/12/201631355
102246151314/12/201645274
102212141614/12/201616340
10222511914/12/201652278
1022435114/12/201652440
1022087314/12/201660305
102235191314/12/201654412
1022519714/12/201659320
10223313414/12/201630240
102242121315/12/201646251
102241121115/12/201658407
10222718715/12/201629400
10222141315/12/201662308
10220851315/12/201651344
10225011415/12/201623239
10223610615/12/201612230
102214101015/12/201633328
102227181615/12/201626274
1022298915/12/201652358
1022149315/12/201645292
10221111315/12/201641302
1022478715/12/201620232
102219191515/12/201662236
10221613315/12/201630262
10222061015/12/201652237
102204171015/12/201661325
10223115615/12/201660284
10224271315/12/201612295
102246111316/12/201646375
10223612516/12/201650330
1022322816/12/201619430
1022494916/12/201619317
1022177816/12/201639258
10225011816/12/201650250
1022342516/12/201613357
10220991616/12/201649421
102233181516/12/201623367
102234121016/12/201655283
102227191216/12/201640241
10224351316/12/201627324
10223212616/12/201617272
1022062616/12/201647378
102206161016/12/201627351
1022047216/12/201625412

 

SalesManCodeSalesManNameSalesType
1JackPhone
2MichaelPhone
3SusanDirect
4LinaDirect
5JohnInternet
6AliceAgent
7PhillipAgent
8MinaInternet
9TinaInternet
10FizanInternet
11AnnaPhone
12PeterAgent
13ShengAgent
14ShuhnAgent
15SonPhone
16HellienInternet
17AntonyPhone
18HanDirect

 

ProductCodeProductNameProductLineProductCategory
1AL1C1
2BL1C1
3CL1C1
4DL2C1
5EL2C1
6FL3C2
7GL3C2
8HL4C2
9IL4C2
10KL4C2
11LL5C3
12ML5C3
13NL5C3
14OL6C3
15PL6C3
16QL6C3
17SL7C3

 

I need to create a report to calculate the avg of lineproduct per each SalesmanType daily! it means i have to avg how many lineproducts sold per each SalesmanType in daily. Could anyone give some advices?

Regards,
J.

9 REPLIES 9
gooranga1
Power Participant
Power Participant

Could you do it with either a matrix or a bar chart with a calculated measure?

 

Average orders.PNG

Hi,
For example, in 12/12/2016:

The salesman Jack sold:

12 product A --> Product line L1

11 product B --> Product line L1

9  product C --> Product line L2

The salesman Susan sold:

11 product A --> Productline L1

14 product C --> Productline L2

22 product G ---> Product L3

 

-->  2 Productlines sold in 12/12/2016 by Lina

---> 3 Productlines sold  in 12/12/2016 by Susan

 

Because Lina and Susan belong to Direct type  --> measure = SUM(count(distint(productline))/count(distinct(salesmancode) = 3/2=1,5

 

In order table only contains salesmanCode and productCode, so please attention to the calculation for productline and salesmantype

 

 

Regards,
J.

 

Hi @MichaelJackpbi,

 

I think it's just simple with: 

 

AVG = DIVIDE(DISTINCTCOUNT('Product'[ProductLine]),DISTINCTCOUNT(SalesMan[SalesManCode]))

 

 Please check this expression with your data and let me know if it's working or not.

@tringuyenminh92

 

I dont think the rule was simple like you wirten, please look at the order table- it contains the productcode and the salesmancode but we need to calculate for productline & SalesType that are higher levels.

@MichaelJackpbi

 

PL = CALCULATE(COUNTROWS(VALUES(Products[ProductLine])))

 

CountSalesMan = CALCULATE(COUNTROWS(VALUES(Orders[SalesManCode])))

 

AVG = [PL]/[CountSalesMan]

 

imag.png




Lima - Peru

@Vvelarde Thank for your comment,
It seems like incorrect, but i mean the number of productline / number of salesType( not salemancode)- has any difference between 2 levels?
+Look at the image, i can see the figures for P/L and CountSalesMan were incorrect in total
I see you countrows in Product table to have number of ProductLine but is it true for Order table ?

I really hope you help me to explain more about your rules and give me the pbix file for further references.

Regards,
J.

 

Hi @MichaelJackpbi,

 

I would like to help your case. Could you please show your expectation in excel file? so i could understand your requirement correctly.

Please help me!.

Please help!.

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.