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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Syndicate_Admin
Administrator
Administrator

Help to get a measurement as a constant

Hello I have a table with customer sales lines, and each row is assigned to an agent (numerico). I need to take out a measure that is fixed, that is the average of the sum of the number of (distinct) clients of the agents that I specify.

Example: I want the average number of clients of agent 23, 24 and 25

agent 23 has (distinct) clients = 50

agent 24 has (distinct) clients = 70

agent 25 has (distinct) clients = 60

media = 180/3 = 60

and q that average does not vary as long as I do not change the codes of the agents by code, or add/ remove agents.

I'm trying with averagex but I can't get it.

Thank you.

1 ACCEPTED SOLUTION

Hi @ivanmoreno ,

I created a sample pbix file(see attachment), please check whether that is what you want. I created two measures as below, please check which one is your expected result. 

average of agents = 
VAR _tab =
    SUMMARIZE (
        'Table',
        'Table'[agent],
        "@coutofclients", CALCULATE ( DISTINCTCOUNT ( 'Table'[client] ) )
    )
RETURN
    AVERAGEX ( _tab, [@coutofclients] )
avarage 2 = 
VAR _sumofclients =
    CALCULATE ( DISTINCTCOUNT ( 'Table'[client] ), ALL ( 'Table' ) )
VAR _countofagent =
    CALCULATE ( DISTINCTCOUNT ( 'Table'[agent] ), ALL ( 'Table' ) )
RETURN
    DIVIDE ( _sumofclients, _countofagent )

yingyinr_1-1639987958407.png

Best Regards

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Syndicate_Admin ,

 

AverageX(values(Table[agent]), Calculate(distinctcount(Table[clinet] ) ) )

Hello, so I get the average of customers of all agents, but I need to specify the agents I want

Hi @ivanmoreno ,

I created a sample pbix file(see attachment), please check whether that is what you want. I created two measures as below, please check which one is your expected result. 

average of agents = 
VAR _tab =
    SUMMARIZE (
        'Table',
        'Table'[agent],
        "@coutofclients", CALCULATE ( DISTINCTCOUNT ( 'Table'[client] ) )
    )
RETURN
    AVERAGEX ( _tab, [@coutofclients] )
avarage 2 = 
VAR _sumofclients =
    CALCULATE ( DISTINCTCOUNT ( 'Table'[client] ), ALL ( 'Table' ) )
VAR _countofagent =
    CALCULATE ( DISTINCTCOUNT ( 'Table'[agent] ), ALL ( 'Table' ) )
RETURN
    DIVIDE ( _sumofclients, _countofagent )

yingyinr_1-1639987958407.png

Best Regards

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.