cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
itchyeyeballs Skilled Sharer
Skilled Sharer

AVERAGEX Conditional Logic

Hi all,

 

I'm having trouble getting an averagex function to work correctly, my data has one row per person, I need a function that checks a flag column then choses which column to sum as appropriate.

 

At the moment it seems to be evaluating for more than one person at a time as I'm getting an error about multiple values. Code is below, can anyone sugest a solution?

 

=AVERAGEX (
        VALUES ( table[Person_ID] ),
        IF (
            values(table[flag]) = 1,
            sum( table[Col1] ),
            sum(table[Col2])
        )
    )

Than you

1 REPLY 1
Super User IV
Super User IV

Re: AVERAGEX Conditional Logic

MyAverageX = AVERAGEX(table,IF(table[flag]=1,table[Col1],table[Col2]))

As a measure.


---------------------------------------

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors