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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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