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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Power_It_Up
Helper I
Helper I

Average total for month / For values greater than zero

Hi there,

 

Here is an example of my DAX requirement.  It's to average ValueA by ValueB, but only if there is a value for ValueB (see below example):-

 

Month.....ValueA.....ValueB......ExpectedResult

JAN..............100............22....................4.55.............

FEB..............150.............37....................4.05.............

MAR............197........................................0................

 

My aim is to calculate the current yearly running average and place into a scorecard, but don't want to include months that do not have a value for ValueB.

 

So for the above example, it would be (100+150) / 22+37) = 4.24 (excluding MAR and any future months.

 

Many thanks in advance. 🙂

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, @Power_It_Up 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1706495707354.png

Measures:

 

Measure A = SUM('Table'[ValueA])

Measure B = SUM('Table'[ValueB])

Average =

CALCULATE (

    DIVIDE ( 'Table'[Measure A], 'Table'[Measure B] ),

    FILTER ( 'Table', 'Table'[Measure B] > 0 )

)

 

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
v-yaningy-msft
Community Support
Community Support

Hi, @Power_It_Up 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1706495707354.png

Measures:

 

Measure A = SUM('Table'[ValueA])

Measure B = SUM('Table'[ValueB])

Average =

CALCULATE (

    DIVIDE ( 'Table'[Measure A], 'Table'[Measure B] ),

    FILTER ( 'Table', 'Table'[Measure B] > 0 )

)

 

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

@v-yaningy-msft 

Hi Yang.  Many thanks for your calc and demo.  This worked well! 🙂

bhanu_gautam
Super User
Super User

@Power_It_Up , Try using below mentioned method

 

RunningAverage =
CALCULATE(
AVERAGE(Table[ValueA]),
FILTER(
ALL(Table),
NOT(ISBLANK(Table[ValueB]))
)
)

 

Please accept as solution and give kudos if it helps




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






It's nearly there, but it's not just the average of ValueA.  It's dividing ValueA by ValueB as long as there is a ValueB in the month.  Thanks again. 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!