Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

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 Sage
Solution Sage

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.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.