cancel
Showing results for
Did you mean:
Helper I

## Help to accumulate data for every hour

Hallo

Hope somone can help me. I want to accumulate data for every houer and i have tried, but i dosent work for me.

Var ind = CALCULATE(DISTINCTCOUNT(AccesData[LineId]),
FILTER(ALL(AccesData), AccesData[Houer] <= SELECTEDVALUE(AccesData[Houer])),
FILTER(AccesData, AccesData[Direction] = "in"))

can someone help me, so hourt 11 wil be all hour 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11??

Best regards Andreas
1 ACCEPTED SOLUTION
Helper I

Hey - i got a solution for it.

Antal =
VAR LastVisibleDate =
MAX ( AccesData[Houer] )
VAR FirstVisibleDate =
MIN ( AccesData[Houer] )
VAR LastDateWithSales =
CALCULATE (
MAX ( AccesData[Houer] ),
REMOVEFILTERS () -- Use ALL ( Sales ) if REMOVEFILTERS () and ALL ()
-- are not available
)
VAR ind =
IF (
FirstVisibleDate <= LastDateWithSales,
CALCULATE (
DISTINCTCOUNT(AccesData[LineId]),
AccesData[Houer] <= LastVisibleDate, AccesData[Direction] = "in"
)
)

var ud =
IF (
FirstVisibleDate <= LastDateWithSales,
CALCULATE (
DISTINCTCOUNT(AccesData[LineId]),
AccesData[Houer] <= LastVisibleDate, AccesData[Direction] = "out"
)
)
RETURN
ind - ud

from google, and it works. but i dont understand why the othe way not work.

Thank for ypu help anyway.
4 REPLIES 4
Solution Supplier

Try without the Filter function.  Internally, the DAX engine will use the Filter function automatically, but only on the column (eg  AccesData[Houer]) rather than the whole table.

CALCULATE(
DISTINCTCOUNT(AccesData[LineId]),
AccesData[Houer] <= SELECTEDVALUE(AccesData[Houer]),
AccesData[Direction] = "in"
)
Helper I

Hallo

Thank you - but i fails?? and dont view enything.

Thay say - selected walue is useb by a true/false, but not alowed in table context

Solution Supplier

Do you have some example data you can share?

Helper I

Hey - i got a solution for it.

Antal =
VAR LastVisibleDate =
MAX ( AccesData[Houer] )
VAR FirstVisibleDate =
MIN ( AccesData[Houer] )
VAR LastDateWithSales =
CALCULATE (
MAX ( AccesData[Houer] ),
REMOVEFILTERS () -- Use ALL ( Sales ) if REMOVEFILTERS () and ALL ()
-- are not available
)
VAR ind =
IF (
FirstVisibleDate <= LastDateWithSales,
CALCULATE (
DISTINCTCOUNT(AccesData[LineId]),
AccesData[Houer] <= LastVisibleDate, AccesData[Direction] = "in"
)
)

var ud =
IF (
FirstVisibleDate <= LastDateWithSales,
CALCULATE (
DISTINCTCOUNT(AccesData[LineId]),
AccesData[Houer] <= LastVisibleDate, AccesData[Direction] = "out"
)
)
RETURN
ind - ud

from google, and it works. but i dont understand why the othe way not work.

Thank for ypu help anyway.

Announcements

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.