Forum Discussion
Average Calculation in Table Visual
Hi Community - I am trying to obtain the Average Headcount (in Average HC) column in a table visualization; however I need some help with the calculation.
The average HC will be calculated as follows:
1st Row in the table (irrespective of the month) - 1000/1
2nd Row in the table - (1000+1500)/2
3rd Row - (1000+1250+1335)/2
so on and so forth...
Is there a way to get this? I am assuming this might be a simple DAX, but i am quite new to this.
Note: Not sure if this helps but I have a column in my data set called "HC" which has the value "1" for each row. The sum of this for each month is what reflects in HC column in the below table.
Unfortunately, as the data is company sensitive I am unable to share the screenshot of the table visualization that I have built in PBI.
Appreciate your help and support! Thanks!
9 Replies
- AnonymousNot applicable
Hi tanmaym93 ,
Is this result you want to achieve?
If it is, you can according to my testing process:
For easy calculation and clear understanding, I create an index column and two measures
- For index column, you can add it in power query
- The first measure is to calculate the Cumulative value:
You can try this measure:
Cumulative value = var _hc=SELECTEDVALUE('Table'[HC]) return SUMX(FILTER(ALL('Table'),'Table'[HC]<=_hc),'Table'[HC])then you can get the Cumulative value:
3. The second measure is what you want to calculate—the average of HC
You can use this measure:
avg hc = 'Table'[Cumulative value]/SELECTEDVALUE('Table'[Index])and finally , the result is as the above shows
Best regards,
Community Support Team Selina zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- tanmaym93Frequent Visitor
Hi Selina - This is the result I am looking to achieve, however my HC value is calculated as a Sum of the HC column that I have in my dataset..
My dataset has 18k rows and I have assigned the value "1" for all the rows.
As a result, I am unable to obtain the result through the Cumulative value measure you suggested.
Let me know if you need additional information from me that can assist you.
- AnonymousNot applicable
Hi tanmaym93 ,
I am not sure I have understood what you mean.
so this HC value doesn't the actual data?
and this is the new HC value which needs to be calculated average value?
If it is convenient for you, you can send me a sample data
Best regards,
Community Support Team Selina zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- tanmaym93Frequent Visitor
Hi Selina - My apologies for any confusion,
Here is the redacted data subset from my PBI data table.
Basically, I have appended 2 sets of data - 1 is the Headcount report and 1 is the Exit report.
I have then added a column called HC_New which returns the value of 1 if the row comes from the Headcount report and 0 if not.
Similarly I have added a column called Exit_New which returns the value of 1 if the row comes from the Exit report and 0 if not.
Using this, I have sumof HC_New which gives me the month on month HC total..
and sumof Exit_new which gives me the month on month Exit total...
Best Regards
Tanmay Mukherjee
- JayawanthNew Member
How to calculate average of 4 rows in PowerBi visual table? Please help me with the forula to create a new Measure