Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello!
I'm quite new to Power BI and I got almost everything I need from my visual but one thing : an average column of the shown columns. Here is what I have so far :
How can I achieve this goal? It is quite easy in excel of course but I can't google the right words to find a tutorial to do it in Power BI.
I'm using Power BI Desktop.
Thank you!
Solved! Go to Solution.
Hi @volt26
Sure, you can try this:
MEASURE =
VAR _vtable =
SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[ID], 'Table'[Num], "_AVG", [AVG] )
RETURN
AVERAGEX ( _vtable, [_AVG] )
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I also realized the average I'm looking for should be the average of all the articles. So that would be :
((10*20)+(6*10)/30)=8.67 per item
The 130 AVG I got in my screenshot is another calculation (60+200)/2
While getting this result also interest me, my main goal is to get the 8.67 result.
Hi @volt26
Please try this:
AVG =
VAR _currentID =
SELECTEDVALUE ( 'Table'[ID] )
VAR _currentNum =
MAX ( 'Table'[Num] )
VAR _vtable =
ADDCOLUMNS (
ALLSELECTED ( 'Table' ),
"_product", 'Table'[Values] * 'Table'[Vendu]
)
VAR _vtable2 =
SUMMARIZE (
_vtable,
'Table'[ID],
'Table'[Num],
"_Sum",
SUMX (
FILTER ( _vtable, [ID] = EARLIER ( [ID] ) && [Num] = EARLIER ( [Num] ) ),
[_product]
)
)
RETURN
SUMX (
FILTER (
_vtable2,
[ID] = SELECTEDVALUE ( 'Table'[ID] )
&& [Num] = MAX ( 'Table'[Num] )
),
[_Sum]
)
/ SUMX (
CALCULATETABLE (
VALUES ( 'Table'[Vendu] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[ID] = _currentID
&& 'Table'[Num] = _currentNum
)
),
[Vendu]
)
The result is 8.67:
If you want 130, please change the return into:
SUMX (
FILTER (
_vtable2,
[ID] = SELECTEDVALUE ( 'Table'[ID] )
&& [Num] = MAX ( 'Table'[Num] )
),
[_Sum]
)
/ CALCULATE (
COUNT ( 'Table'[Num] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[ID] = _currentID
&& 'Table'[Num] = _currentNum
)
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Wow! What you did is fantastic!
I'll push my luck and ask an extra question but if this should be in another thread simply tell me I will do so. I'm aware that you probably want me to click the accept as solution button by now! 🙂
So...
Now that I have the AVG for each selected cycle, is it possible to have a column that will show the average of the averages? Like this :
(sum of all selected Num columns)/(amount of Num columns selected) = Average of averages
(4+7+1+8.67+9)/5=5.934
Hi @volt26
Sure, you can try this:
MEASURE =
VAR _vtable =
SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[ID], 'Table'[Num], "_AVG", [AVG] )
RETURN
AVERAGEX ( _vtable, [_AVG] )
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you very much for your help!
I apologize, I realize I should've given more information about my pbix file. Unfortunately, the numbers you see in my screenshot are not static. They are from a formula that grabs static data from other tables.
Example :
the 1,1 you see in the upper left cell represents how many transactions per day were made in average in that week.
So we can read that in week 1, the second name did 1,2 transactions per day. Then he did 0,2 in week 2. Week 3 shows no number because he wasn't at work or did 0 transactions.
Now these numbers are calculated from other measures and that is were my problem is... I can't quite grasp the concept of making an average with the numbers shows in the table as they are not static but obtained from measures.
I'm trying to recreate this challenge with your table. I added a new column named sold and entered transactions :
Now in Power BI I tried many things but I just can't get your formula to work because it calls static data from the table while I'm trying to get the average of measurments. I think I'm close to my goal...
Here is where I am right now :
I shared the files on my google drive : https://drive.google.com/file/d/1oljHM1qoQpainfHB8uj3Lzu_miwsGFmh/view?usp=sharing
Thank you for your help!
Hi @volt26
Please try this:
Here I create a set of sample for your reference:
Then add a measure:
MEASURE =
VAR _currentID =
SELECTEDVALUE ( 'Table'[ID] )
RETURN
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = _currentID )
)
/ CALCULATE (
DISTINCTCOUNT ( 'Table'[Num] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = _currentID )
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
90 | |
84 | |
70 | |
49 |
User | Count |
---|---|
143 | |
121 | |
112 | |
59 | |
58 |