Pivot table DAX measure for column average - excel

I have a list of rooms sitting in a single column of a data set. I have put this list into a pivot table with a count of the room numbers. I want to add a dax measure on the pivot table to work out the column average.
I only have read access to the raw data and also I need to keep the size down as the table has 1.5m lines. Running groupby and column averages in power query takes more time and space then I have.
As an example, the below is a list of rooms that have been put into a pivot table. I have then added a count of the rooms. How can I create a measure off a pivot table count where that count is not / can not be in the raw data. The average figures is 3.66 which would be expressed in each cell of the column average column.
ROOMS
COUNT
COLUMN AVERAGE?
ROOM1
02
ROOM2
05
ROOM3
04
Thanks

Your measure needs to transition context to ALL rooms, when dividing the count of rows, by the distinct rooms values:
=CALCULATE (
DIVIDE (
COUNTROWS ( Table1 ),
DISTINCTCOUNT ( Table1[Rooms] ),
BLANK()
),
ALL ( Table1[Rooms] )
)

Related

Excel Pivot table Grand Average that includes 0's in total average

I have a custom Measure in my excel data model so I can calculate Grand Average in a pivot table...
MyMeasure:=VAR T1 =
SUMMARIZE(HC_Data,HC_Data[data date (Month)], "Total HC", [Count of NAME]) RETURN
IF(HASONEVALUE(HC_Data[data date (Month)]), SUM(HC_Data[HC count]), AVERAGEX( T1, [Total HC]))
now, at first sight, this works wonders! BUT, it doesn't take into accounts months with 0's since the source data wouldn't have a record if there is a 0 in the pivot table.
The pivot table will show a 0 since the columns months are based on a full calendar, and pivot set to show 0 when there is no record. so what i need is a way that the custom Measure accounts for 0's.. is this possible?
Create a new table comprising a unique list of entries from the data date (Month) column and create a relationship between this new table and HC_Data. You can then amend your measure to:
MyMeasure:=VAR T1 =
SUMMARIZE( Months, Months[Month], "Total HC",[Count of NAME] )
RETURN
IF(
HASONEVALUE( HC_Data[data date (Month)] ),
SUM( HC_Data[HC count] ),
AVERAGEX( T1, [Total HC] )
)
I have assumed that the new table is called Months and comprises a single column called Month.

Need to find the average of all values in pivot table

I have a data table that is pulling all successful contacts by case manager over a period of time. We've created a pivot table of the data that groups by case manager for the rows and by month of the contact for the columns. It counts the appointment IDs to get counts per case manager per month.
My manager wants this data displayed in a chart to easily visualize the data. The part I can't get is she wants the average contacts per month over all the case managers and all the months to be displayed on the chart. Essentially, she wants the average of all the values in the pivot table.
I've played around with power pivot and the DAX functions averagex() and summarize() to get averages in the total row per column, but the ultimate grand total is still the average of the totals.
How can I get the average of all the fields by itself?
Here is the sample pivot table with the totals per case manager per month
Here are the totals using averagex(summarize()) to get counts for the values and average for the totals.
AVERAGEX ( SUMMARIZE ( Table1, [Caseload], "x", COUNTA ( [Client ID] ) ), [x] )
However, the real average I want to see is 34 (all the values averaged together
You need to summarize by month as well to be able to average the way you want.
avg_count =
AVERAGEX (
SUMMARIZE (
Table1,
Table1[Caseload], --Assuming this is what you have on the rows
Table1[Month], --Assuming this is what you have on the columns
"x", COUNTA ( Table1[Client ID] )
),
[x]
)

Sum columns in Power BI matrix

I am working on a matrix in Power BI and I am not figuring out how to sum each column recursively until the total:
And this should be the resulting matrix (as an example, rows):
Some clarifications:
The months (columns) are dynamically generated based on the transaction month. I could filter the data to get the same data for only three months.
"Nombre proveedor" stands for "Vendor name".
I don't care about "Total" row.
These are my values:
So, I think I should create a measure with DAX to replace "Accounting Balance" to sum the previous column (month) or show nothing (to avoid zeroes).
Searching on internet I found several sites to get the running totals by rows, but not by columns.
Any suggestions?
Try Something like this:
Maesure =
CALCULATE (
[Accounting Balance],
FILTER (
ALL ( 'table' ),
'table'[Transaction month] <= MAX ( 'table'[Transaction month] )
)
)

Sum in pivot hierachy

I have the following DAX-formula to retrieve the opening and closing balance for a list of products.
=CALCULATE(MAX(transactions[Balance]);
FILTER(transactions;
transactions[ID] = MAX(transactions[ID])
)
)
This works on row level in my Pivot but when I group this och Product category level I only get one value and not the sum of all the product rows.
My data contains of rows for each transaction and each row have a columns with current balance.
How do I sum each row to get the group sum for the above category "00-01" 26784 and 283500?
One way to do this is to leverage an iterative function like a SUMX.
Assuming that your EndValue is the measure that you defined.
SUMX_Example := SUMX( VALUES ( transactions[ID] ) , [EndValue] )
Which will do the following:
Though VALUES ( transactions[ID] ) it will generate a list of your IDs
For each ID it will run your already created [EndValue] measure
Sum the result of each ID's end value
This is of course assuming [ID] does not cover categories. If ID does cross categories, then you would first do a SUMX using category, with another SUMX that does ID

How can I get a percentage field with power pivot?

This should be a fairly easy question for Power Pivot users since I'm a newbie. I am trying to do the following. After pivoting a table I get a crosstab table like this
rating count of id
A 1
B 2
Grand Total 3
You can imagine the original table only has two columns (rating and id) and three rows (1 id for A and two different id's for the B rating). What DAX formula do I have to write in order to create a measure that simply shows
rating percent of id
A 1/3
B 2/3
Grand Total 3/3
By 1/3 of course I mean 0.3333, I wrote it like that so that it is clear that I simply want that percent of id is the count for each rating divided by the total count. Thank you very much
You need to divide the count for each row by the total count.
DIVIDE (
COUNT ( Table1[ID] ),
CALCULATE ( COUNT ( Table1[ID] ), ALL ( Table1 ) )
)
For this particular calculation, you don't have to write DAX though. You can just set it in the Value Field Settings.
Summarize Value By : Count
Show Values As : % of Column Total

Resources