While I have already asked this question under the Power BI Tools section, it appears that part of the site gets less visits, my frustration has continued and I am trying to understand the mechanics of the COUNTIFS function, as I can replicate the issue with normal Excel formula if i break it down into steps. So if i can find the solution in normal Excel, perhaps I can figure out the solution in Power Pivot.
My original post is Pivot Table Measure To Calculate Items Between Range Returning Wrong Result
Using the example data (with just 1 company)
Then using the Measure
results in the Pivot Table below. To the right hand side are the results using CountIfs(), which are what the answer should be (and is checked against filtering the data for each 30min period).
The yellow highlights the difference.
If I break the CountIfs down into SiteEntry & SiteExit and then Min(SiteEntry, SiteExit), similar to the Measure, I replicate the Pivot Table result.
Can anyone advise how I can achieve the desired result without using the normal CountIfs solution??
While only testing on a small subset of data, this will be used daily on a large data set, and I need to find an easy and robust solution that anyone can use by just adding the data into the spreadsheet.
regards
Kris
My original post is Pivot Table Measure To Calculate Items Between Range Returning Wrong Result
Using the example data (with just 1 company)
Then using the Measure
Code:
Number On Site
=
VAR vMinVal = MIN(tbl_TimeGroup[Value])
VAR vMaxVal = MAX(tbl_TimeGroup[Value])
VAR vSiteEntry = CALCULATE( COUNTROWS(tbl_SiteEntryExit), tbl_TimeGroup[Value] <= vMinVal, ALL(tbl_TimeGroup))
VAR vSiteExit = CALCULATE( COUNTROWS(tbl_SiteEntryExit), tbl_TimeGroup[Value] >= vMaxVal, ALL(tbl_TimeGroup), USERELATIONSHIP(tbl_SiteEntryExit[OUT Swipe (Group)], tbl_TimeGroup[Value]))
RETURN
MIN(vSiteExit, vSiteEntry)
The yellow highlights the difference.
If I break the CountIfs down into SiteEntry & SiteExit and then Min(SiteEntry, SiteExit), similar to the Measure, I replicate the Pivot Table result.
Can anyone advise how I can achieve the desired result without using the normal CountIfs solution??
While only testing on a small subset of data, this will be used daily on a large data set, and I need to find an easy and robust solution that anyone can use by just adding the data into the spreadsheet.
regards
Kris