cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
andreasalleslev
Helper I
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.

 

Antal på pladsen =
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??
 
 
acces data feed.jpg
Best regards Andreas
1 ACCEPTED SOLUTION

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.

View solution in original post

4 REPLIES 4
PaulOlding
Solution Supplier
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"
)

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

Do you have some example data you can share?

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.

View solution in original post

Helpful resources

Announcements
MBAS on Demand

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.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors