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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors