I have had my first attempt at creating a Measure for a Pivot Table to solve a problem, but I am not getting the expected results.
I am looking to calculate the number of people in an area between 2 times (Log In & Log Out using a swipe card), including a split by company.
I've followed a post on a PowerBI site Start and end time but using either of the solutions put forward I get issues
When using
The Pivot Table has some instances by Company & Time period that are incorrect, and more bizzarely, the Grand Total doesnt add up.
I havent found a way to drill down or evaluate the Measure, so I cant work out where I may of gone wrong.
An example of this is from the data below at 10am, the Measure returns 8no rather than 7no (red text)
The second solution gives the correct Grand Totals for each Time period, but wont split by Company (I just get the overall total)
Can anyone advise where I may of gone wrong?
And/ Or any good resources to start learning the basics??
Thanks
Kris
I am looking to calculate the number of people in an area between 2 times (Log In & Log Out using a swipe card), including a split by company.
I've followed a post on a PowerBI site Start and end time but using either of the solutions put forward I get issues
When using
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 Pivot Table has some instances by Company & Time period that are incorrect, and more bizzarely, the Grand Total doesnt add up.
I havent found a way to drill down or evaluate the Measure, so I cant work out where I may of gone wrong.
An example of this is from the data below at 10am, the Measure returns 8no rather than 7no (red text)
Company | IN Swipe (Group) | OUT Swipe (Group) |
---|---|---|
Company A | 06:00 | 18:00 |
Company A | 06:30 | 16:00 |
Company A | 06:30 | 16:00 |
Company A | 06:30 | 16:30 |
Company A | 06:30 | 16:30 |
Company A | 07:00 | 15:30 |
Company A | 08:00 | 09:30 |
Company A | 08:00 | 13:00 |
Company A | 11:30 | 11:30 |
The second solution gives the correct Grand Totals for each Time period, but wont split by Company (I just get the overall total)
Code:
Number On Site 2
=
VAR vMinVal = MIN(tbl_TimeGroup[Value])
VAR vMaxVal = MAX(tbl_TimeGroup[Value])
VAR vNumberOnSite = COUNTROWS( FILTER( ALLSELECTED(tbl_SiteEntryExit), tbl_SiteEntryExit[] <= vMinVal && tbl_SiteEntryExit[] >= vMaxVal))
RETURN
vNumberOnSite
Can anyone advise where I may of gone wrong?
And/ Or any good resources to start learning the basics??
Thanks
Kris