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
rdantasss
Frequent Visitor

DAX Average with filter

Hi!

 

I want to make a new measure with an Average and a filter.

 

There's my data:

 

MEDIA POWERBI.png

 

On Powerbi, I want a measure of an average from year 2018 and other measure with year 2019.

 

How can I do this on PB ?!

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @rdantasss 

Try creating these two measures and place them, for instance, in a card visual. Table1 is the table you show:

 

AVG_2018 =
CALCULATE ( AVERAGE ( Table1[Quant] ), Table1[Year] = 2018 )
AVG_2019 =
CALCULATE ( AVERAGE ( Table1[Quant] ), Table1[Year] = 2019 )

  

Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. That allows people trying to help to readily copy the data and run a quick test, plus it increases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here.

View solution in original post

4 REPLIES 4
JCARRASCOA
New Member

thanks

AlB
Super User
Super User

Hi @rdantasss 

Try creating these two measures and place them, for instance, in a card visual. Table1 is the table you show:

 

AVG_2018 =
CALCULATE ( AVERAGE ( Table1[Quant] ), Table1[Year] = 2018 )
AVG_2019 =
CALCULATE ( AVERAGE ( Table1[Quant] ), Table1[Year] = 2019 )

  

Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. That allows people trying to help to readily copy the data and run a quick test, plus it increases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here.

rdantasss
Frequent Visitor

Thanks for your help and your insight about the sample data!

@rdantasss 

A simpler, more scalable, way of doing it:

 

1. Place Table1[Year] in the rows of a visual matrix

2. Create the following measure and place it in the matrix visual: 

Answer_Perc =
AVERAGE( Table1[Quant])

With that you'll have one measure that can be used for all years, with the result for each on the rows of the matrix visual   

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.