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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
scorbin
Helper I
Helper I

How to filter by date on a CALCULATETABLE and SUMMARIZE function?

I have a table that is pulling data from an excel work book. This table is then appended to combine with a table that is coming from a SQL query. I am trying to filter the dates on the excel table to match the results from the SQL query. 

The excel data looks like this: 

DateMachineTimeJob
4/9/2022Alpha41098
8/23/2022Beta3.5

1702

8/23/2022Beta21701
9/30/2022Delta4.51104
10/01/2022Alpha3

1093

 

Right now I have this DAX:

SUMMARIZEMachine = 
CALCULATETABLE(
SUMMARIZE(
'MachineRunTime'
,MachineRunTime[Date]
,MachineRunTime[Machine]
,MachineRunTime[Time]
,MachineRunTime[Job]
)
,FILTER(ALL(
MachineRunTime
), FORMAT(MachineRunTime[Date], "Short Date") >= FORMAT(DATEADD(MachineRunTime[Today], -84, DAY), "Short Date"))

)

That creates a table for me, but it doesn't acutally filter the Date column and it shows all the data. How can I fix this so the Date column is filtered correctly? Note that I created a "Today" column in the original table within Power BI so I could use the DATEADD() function. 

1 ACCEPTED SOLUTION
scorbin
Helper I
Helper I

I realized that I don't need the DATEADD function to get the results I need. Coming from a SQL background, I mistakenly thought that might be needed. 

Solution was as follows: 

SUMMARIZEMachine = 
CALCULATETABLE(
SUMMARIZE(
'MachineRunTime'
,MachineRunTime[Date]
,MachineRunTime[Machine]
,MachineRunTime[Time]
,MachineRunTime[Job]
)
,FILTER(
ALL(SecureMachineRunTime)
,MachineRunTime[Date] >= TODAY() - 42
)
)

View solution in original post

1 REPLY 1
scorbin
Helper I
Helper I

I realized that I don't need the DATEADD function to get the results I need. Coming from a SQL background, I mistakenly thought that might be needed. 

Solution was as follows: 

SUMMARIZEMachine = 
CALCULATETABLE(
SUMMARIZE(
'MachineRunTime'
,MachineRunTime[Date]
,MachineRunTime[Machine]
,MachineRunTime[Time]
,MachineRunTime[Job]
)
,FILTER(
ALL(SecureMachineRunTime)
,MachineRunTime[Date] >= TODAY() - 42
)
)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.