Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
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. 🙂
Solved! Go to Solution.
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.
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
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.
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
Hi Yang. Many thanks for your calc and demo. This worked well! 🙂
@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
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.
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
33 | |
16 | |
13 | |
10 | |
8 |
User | Count |
---|---|
59 | |
20 | |
12 | |
11 | |
10 |