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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hanygameel
Helper I
Helper I

Average by more values

i have table that have

Patient ID   invoice no.      Doctor    Service No.  Amount   Episode No. ( visit No)

001                  22-01              10            654              50              01

001                  22-01              10           859               100            01

002                  22-02              09            357               75             01

002                  22-02              09            658               650           01

 

Episode No. serial from 1 for each patient

how can i calculate average amount by Episode for each patient ?

 

2 ACCEPTED SOLUTIONS
FreemanZ
Super User
Super User

Hi  @hanygameel 

 try to create a measure with this:

AvgByPatientByEpisode =
AVERAGEX(
    SUMMARIZE(
        TableName, 
        TableName[Patient ID],
        TableName[Episode No.]
    ),
    SUM(TableName[Amount])
)

 

In case of failure, please provide more data to cover the complexity of your case. 

 

View solution in original post

@hanygameel 

  • You can add a column inside SUMMARIZE which is the SUM of the ammount aggregated at the Episode level (which is most probably one value) the FILTER will consider only the values that are above 0 the the averaging is performed. 

View solution in original post

10 REPLIES 10
hanygameel
Helper I
Helper I

Thanks for your quick response

it gives me the total amount

tamerj1
Super User
Super User

Hi @hanygameel 

it depends of which column are you slicing by in your visual. If you are slicing by Patient ID then AVERAGE ( 'Table'[Amount] ) will do. Unless you need to sum the averages at the grand total level the you can use

SIMX ( VALUES ( 'Table'[Patient ID] ), CALCULATE ( AVERAGE ( 'Table'[Amount] ) ) )

I need to calculate the average episode amount for the doctor

in other way, I need the average amount paid by the patient in the episode ( doctor visit )

@hanygameel 

Please try

Average Amount =
AVERAGEX (
FILTER (
SUMMARIZE (
'Table',
'Table'[Patient ID],
'Table'[Episode No.],
"@Amount", SUM ( 'Table'[Amount] )
),
[@Amount] > 0
),
[@Amount]
)

i can not understand this

hanygameel_0-1670747053170.png

 

@hanygameel 

  • You can add a column inside SUMMARIZE which is the SUM of the ammount aggregated at the Episode level (which is most probably one value) the FILTER will consider only the values that are above 0 the the averaging is performed. 

@hanygameel 

  • You can add a column inside SUMMARIZE which is the SUM of the ammount aggregated at the Episode level (which is most probably one value) the FILTER will consider only the values that are above 0 the the averaging is performed. 

Thank you Very Much
i got it

FreemanZ
Super User
Super User

Hi  @hanygameel 

 try to create a measure with this:

AvgByPatientByEpisode =
AVERAGEX(
    SUMMARIZE(
        TableName, 
        TableName[Patient ID],
        TableName[Episode No.]
    ),
    SUM(TableName[Amount])
)

 

In case of failure, please provide more data to cover the complexity of your case. 

 

Also, i need to exclude zero amount from the average calculation

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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