The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello Community
We have a traffic table which consist of
- Timestamp (date)
- Id of shop
- Hours
- Entrance traffic
- Exit traffic
With mesures we counted total traffic per day, both for entrance and exit
Entrance_Shop =
SumX( SUMMARIZE(
'Traffic',
'Traffic'[Timestamp],
'Traffic'[Hour],
'Traffic'[ID Shop.1],
'Traffic'[ID Shop.2],
'Traffic'[Entrance]
),'Traffic'[Entrance])
Exit_Shop =
SumX(
SUMMARIZE(
'Traffic',
'Traffic'[Timestamp],
'Traffic'[Hour],
'Traffic'[ID Shop.1],
'Traffic'[ID Shop.2],
'Traffic'[Exit]
),'Traffic'[Exit])
As a result we have correct data of entrance and exit traffic by days.
Our task is to count deviation of traffic in a specific mathematic way.
sqrt((1550-1278)^2)+((1719-1278)^2)/2)=366
For this example i used data of 2 days 24.05.2022-25.05.2022 and the result should be as calculated abowe.
We divide this data with 2 because we selected 2 days as example. If we will choose more days, formula must divide data with quantity of choosen days.
Our mesure that we use in PBI looks as following:
Deviation =
VAR _AmDates = CALCULATE(COUNTROWS(DATESBETWEEN('Dates'[Date],MIN('Dates'[Date]),MAX('Dates'[Date]))))
VAR _Entrance =
SumX( SUMMARIZE(
'Traffic',
'Traffic'[Timestamp],
'Traffic'[Hour],
'Traffic'[ID Shop.1],
'Traffic'[ID Shop.2],
'Traffic'[Entrance]
),'Traffic'[Entrance])
VAR _Exit =
SumX( SUMMARIZE(
'Traffic',
'Traffic'[Timestamp],
'Traffic'[Hour],
'Traffic'[ID Shop.1],
'Traffic'[ID Shop.2],
'Traffic'[Exit]
),'Traffic'[Exit])
VAR kvadrat =
POWER( ABS( _Entrance-_Exit ), 2 )
Return
DIVIDE( SQRT( kvadrat ), _AmDates)
For some reason if I try to count this in PBI I can not achieve this result. I dont know why but we get result of 356,5 instead of 366
Please help us to understand correct mesure to achieve correct result of 366
Example pbix
Solved! Go to Solution.
Hello Community
After conducting research, we came to the desired result.
The first thing we did was derive a compute table that deduced the value squared.
_traffic =
SUMMARIZE(
'Traffic',
'Traffic'[ID Shop.1],
'Traffic'[Timestamp],
"vx",
POWER(
ABS(
SUM('Traffic'[Entrance]) - SUM('Traffic'[Exit])),2)
)
The second thing that was done was added dimShop and made connections between the tables
And the last stage of creating a measure, I brought the desired result
Deviation =
VAR _AmDates = CALCULATE(COUNTROWS(DATESBETWEEN('Dates'[Date],MIN('Dates'[Date]),MAX('Dates'[Date]))))
VAR kvadrat = SUM('_traffic'[vx])
Return
SQRT( DIVIDE( kvadrat , _AmDates))
Hello Community
After conducting research, we came to the desired result.
The first thing we did was derive a compute table that deduced the value squared.
_traffic =
SUMMARIZE(
'Traffic',
'Traffic'[ID Shop.1],
'Traffic'[Timestamp],
"vx",
POWER(
ABS(
SUM('Traffic'[Entrance]) - SUM('Traffic'[Exit])),2)
)
The second thing that was done was added dimShop and made connections between the tables
And the last stage of creating a measure, I brought the desired result
Deviation =
VAR _AmDates = CALCULATE(COUNTROWS(DATESBETWEEN('Dates'[Date],MIN('Dates'[Date]),MAX('Dates'[Date]))))
VAR kvadrat = SUM('_traffic'[vx])
Return
SQRT( DIVIDE( kvadrat , _AmDates))
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
23 | |
14 | |
13 | |
8 | |
8 |