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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
JoaqBI
Regular Visitor

CALCULATETABLE with SUMMARIZE and Dynamic Filter - Is this possible ?

Hi All,

 

I am learning PowerBI and I am trying to create a table taking 3 columns from another table filtering the project number ( Information of another table) based on a selected value.
CurrentProj = SELECTEDVALUE(Proj_CostSummaries[Project_Number])

 

The Code to create the table is the following :

TimeSpent =
CALCULATETABLE(SUMMARIZE(Proj_CostSummaries,Proj_CostSummaries[Period_Date],Proj_CostSummaries[TS_Total_Cost_Project_Currency],Proj_CostSummaries[Project_Number]), FILTER(Proj_CostSummaries,Proj_CostSummaries[Project_Number] = [CurrentProj]))

I can see all the columns but for some reason the FILTER is not doing anything. If you can help me understand the issue that will be great!
 
4 REPLIES 4
jaweher899
Impactful Individual
Impactful Individual

It looks like the issue is that you are trying to use the selected value of Project_Number as a filter, but you are referencing it using the wrong syntax. In the FILTER function, you should reference CurrentProj directly instead of using the square brackets ([]) around it.

Try changing your code to the following:

TimeSpent = CALCULATETABLE(SUMMARIZE(Proj_CostSummaries,Proj_CostSummaries[Period_Date],Proj_CostSummaries[TS_Total_Cost_Project_Currency],Proj_CostSummaries[Project_Number]), FILTER(Proj_CostSummaries,Proj_CostSummaries[Project_Number] = CurrentProj))

Thanks for your quick response, CurrentProj is defined like this :


CurrentProj = 
SELECTEDVALUE(Proj_CostSummaries[Project_Number])


If I try to change the FILTER with "00688" which is a possible value for Project Number it works 🙄

TimeSpent =
CALCULATETABLE(SUMMARIZE(Proj_CostSummaries,Proj_CostSummaries[Period_Date],Proj_CostSummaries[TS_Total_Cost_Project_Currency],Proj_CostSummaries[Project_Number]), FILTER(Proj_CostSummaries,Proj_CostSummaries[Project_Number] = "00688"))
 
I also tried to show CurrentProj in a card to make sure CurrentProj changes it's value based on the slicer. So I don't know why this is not working.

Thanks again!
jaweher899
Impactful Individual
Impactful Individual

create a measure that counts the rows that match the selected project number, and use that measure as a filter in your code.

CurrentProj = COUNTX(FILTER(Proj_CostSummaries,Proj_CostSummaries[Project_Number] = SELECTEDVALUE(Proj_CostSummaries[Project_Number])))

and then use that measure in your filter.

TimeSpent = CALCULATETABLE(SUMMARIZE(Proj_CostSummaries,Proj_CostSummaries[Period_Date],Proj_CostSummaries[TS_Total_Cost_Project_Currency],Proj_CostSummaries[Project_Number]), FILTER(Proj_CostSummaries,CurrentProj >0))

Thanks @jaweher899 but it seems it does not allow me to use CurrentProj without [].
I have also tried the code you suggested and had the following problems :

JoaqBI_1-1674146379139.pngJoaqBI_2-1674146473914.png

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.