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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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!

Proud to be a Super User!




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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors