Forum Discussion
Calculated column countrows in another table
Is there a way to create a calclulated column that will get a count of records from another table but keeping the report filters?
I have two tables
Employee table with an employee id and a test table with testing information with an employee id of the employee that took the tests.
I have page leve filters and slicers on my report and I would like to add a calculated column to the employee table that counts the number of test the employee took, keeping all the filters.
I have tried keepfilters but this is not working.
5 Replies
- sergej_ogSuper User
Hey tomperro ,
since you have (I guess) a 1:n relationship between the tables you can use RELATEDTABLE (to calculate value from the n-side of the relationship) and store the result in a calculated column.
like so:COUNTROWS(RELATEDTABLE(Sales)).
You have to put the formula on the 1-side of the relationship.
Regards- tomperroHelper V
That does give me the count but it is not applying the filters.
For example, I do not want to count the test number 123 for the employees.
I do not want to put the filter in the formula, I would like to use the page level and slicers already applied.- sergej_ogSuper User
Calculated column works with row context.
If you would like to tweek your results you have to use CALCULATE.
What about get all data (countrows) into calculated column and then work with measures and visualizations to get your goal? You can exlude every thing you want.
It's a bit hard to understand your scenario without seeing any sample data/results.
Regards