Forum Discussion
Frequency calc / Histogram
- 8 years ago
Hi David,
Delete the column "CustID" from Summary. I found that the visual is correct now. Please check the file here: https://1drv.ms/u/s!ArTqPk2pu-BkgSqND4imKbOYtOeh
Summary = SUMMARIZE ( 'Visits', 'Visits'[Site id], "Fres", COUNT ( Visits[Site id] ) )Best Regards!
Dale
It's a frequency table... My column headings were perhaps not clear... The figures are the count of the number of 'occurrences' rather than the number of visits. The table reconciles to 6 visits as follows - [(1+2)]*1] + [(0+0)*2] + [(1+0)*3] = 6 visits.
ABC XYZ
Freq #occur #occur Total #visits
1 1 2 three times to the same site on only occasion, one for ABC & two for XYZ
2 0 0 no visits to the same site twice, by either customer
3 1 0 once to the same site three times, by one of the customers (ABC)
1 Visited a single site on ONE occasion only - ABC - 1 occurrence visited site 123 , XYZ - 2 occurrences visited sites 123 and 345 = 3 visits in total
2 Visited a single site TWICE - none
3 Visited a single site on THREE occasions - ABC - 1 occurrence visited site 345 three times
Hope that helps explain! The DAX logic is beyond me... I could probably do it in Excel, using countif but the database is 100's of thousands lines long so teh spreadsheet would be slow and the ability to cut and dice the results (by period, customer, etc.) would be limited without a lot of manual effort.
Cheers
Hi dapling,
The frequency is dynamic and the possible frequency is also dynamic. So there could be more steps to achieve your goal.
1. Create a summary table.
Summary =
SUMMARIZE (
'Source',
'Source'[CustID],
'Source'[SiteID],
"Fres", COUNT ( Source[SiteID] )
)2. Create a table PotentialFreqs.
PotentialFreqs = GENERATESERIES ( MIN ( 'Summary'[Fres] ), MAX ( 'Summary'[Fres] ), 1 )
3. Establish relationship between PotentialFreqs and Summary.
4. Create a measure.
numberOfFreqs =
VAR nFreqs =
COUNT ( 'Summary'[Fres] )
RETURN
IF ( ISBLANK ( nFreqs ), 0, nFreqs )5. Import a custom visual "Histogram".
6. Create visual.
Please check this file for details: https://1drv.ms/u/s!ArTqPk2pu-BkgReCPUHxVhzv7-Cr
Best Regards!
Dale
- dapling8 years agoFrequent Visitor
Genius, Dale! Thanks.
I've now been asked to provide a slightly different view, which has equally confused me...
Instead of counting frequency by Customer, I need to summarise by Site Owner. We manage multiple sites, some of which we own and some on behalf of other companies.
The OwnerID is held in a separate table which is linked via a relationship on 'SiteID' in table 'VISIT' to table 'OWNER'.
Therefore, in illustration I need:
Any more help you can provide would be much appreciated!
Thanks a lot.
- v-jiascu-msft8 years agoMicrosoft Employee
Hi dapling,
You are welcome. You can create a Column Chart. Besides, I can't see any difference between your two posts. Could you please share your PBIX file? Then I could do more.
Best Regards!
Dale