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
Anonymous
Not applicable

Urgent help needed - average of first instance

I have a table called action items and I am trying to get the average of response values for only the first instance of a users response only if the response type is 99 AND only if there is a response value. Here is the table and I will show the desired output

UserIDResponseIDResponse ValueStatusofResponseDateUpdated
199613/1/2020
299913/3/2020
345100013/3/2020
499 03/3/2020
199313/10/2020
245400013/10/2020
299313/12/2020
     


Desired output:

a measure whose result would be 7.5 (in this case, it was the average of UserIds 1 and 2 responses 6 and 9 respectively) -- userID 3 did not have responseID99 and userID4 had not responded (hence status value of 0). Further, I only wanted the first instance. any help would be greatly appreciated!!

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

See if this works, create the following column:

 

FirstDate = MINX(FILTER('Table',[UserID] = EARLIER([UserID]),[DateUpdated]

 

Now you can create a Measure like so:

 

Measure = AVERAGEX(FILTER('Table',[DateUpdated] = [FirstDate] && [Response ID] = 99 && NOT(ISBLANK([Response Value])),[Response Value])

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Great!

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

See if this works, create the following column:

 

FirstDate = MINX(FILTER('Table',[UserID] = EARLIER([UserID]),[DateUpdated]

 

Now you can create a Measure like so:

 

Measure = AVERAGEX(FILTER('Table',[DateUpdated] = [FirstDate] && [Response ID] = 99 && NOT(ISBLANK([Response Value])),[Response Value])

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler i am not getting any number to appear when i do that 

 

Anonymous
Not applicable

I got it when I changed this Measure = AVERAGEX(FILTER('Table',[DateUpdated] = [FirstDate] && [Response ID] = 99 && NOT(ISBLANK([Response Value])),[Response Value])

 

to 

Measure = AVERAGEX(FILTER('Table', [FirstDate] && [Response ID] = 99 && NOT(ISBLANK([Response Value])),[Response Value])

 

Great!

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.