Forum

Pivot table grand t...
 
Notifications
Clear all

Pivot table grand total doesn't sum a count column but I need it to

8 Posts
2 Users
0 Reactions
62 Views
(@mlinke)
Posts: 39
Trusted Member
Topic starter
 

Hi

I have a pivot table that has a count column (Total Visits), a distinct count column (Unique Visitors) and a sum column (Consumption kWh). In the grand total the number for the distinct count column (Unique Visitors) is not the sum of the numbers above. I don't actually know what it is - it isn't the count or the average of those numbers either. The GTs for the count and sum columns are correct.

Is there any way of making the distinct count GT a sum of the numbers above?

 
Posted : 19/12/2018 9:43 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Mardi,

Please show me the measure formula for Consumption kWh and the row context for the PivotTable so I can understand how the data in the rows is being filtered. If it's confidential then please show the Row Label field name.

Thanks,

Mynda

 
Posted : 19/12/2018 10:55 pm
(@mlinke)
Posts: 39
Trusted Member
Topic starter
 

Hi Mynda

Consumption kWh is Consumption Wh divided by 1000 to add a new column in the query (see attachment). Not sure what the second request means but I've put a screen shot of the whole pivot table in the attachment.

 
Posted : 19/12/2018 11:18 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Mardi,

I can't see anything obvious wrong that would explain the discrepancy, but I'll wait to check your file when you email it to me. I presume it's the same file as the one for your other question.

Mynda

 
Posted : 20/12/2018 12:01 am
(@mlinke)
Posts: 39
Trusted Member
Topic starter
 

It is, thank you so much!

 
Posted : 20/12/2018 5:36 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Mardi,

The problem occurs because the RFID that is being counted is not unique to a charge station i.e. the same RFID can appear in multiple charge stations, but the Distinct Count only counts it once in the total.

I've emailed your file as it's too large to upload here, but you'll see I've added a column to your fact table that concatenates the Charge Station and RFID into a new column and this is what is used for the total DISTINCTCOUNT.

Mynda

 
Posted : 21/12/2018 1:24 am
(@mlinke)
Posts: 39
Trusted Member
Topic starter
 

Thanks for doing this, it's much appreciated.

I've been looking at the DAX formula you used for the measure "Distinct Visits". It's an IF statement using the HASONEFILTER formula on the column "Charger Name". I'm not sure I understand HASONEFILTER; does it mean that if the Charger Name has been filtered to one value then use DISTINCTCOUNT of RFID, and if it has not been filtered to one value use DISTINCTCOUNT of "Station ID" (your new column)? So for the rows where there is a filter which returns one Charger Name it counts the distinct entries in the column RFID, and for the grand total where there is no filter it counts the distinct entries in Station ID?

 
Posted : 21/12/2018 8:17 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Mardi,

Correct. HASONEFILTER checks to see if there is a single filter applied to a row, Total rows are unfiltered, so it allows us to provide a different calculation for Totals and the other rows.

Mynda

 
Posted : 22/12/2018 12:09 am
Share: