Make a count of records with a function in the same table but filtered by a field in Current record ?

RasmusKA

New Member
Joined
Apr 17, 2013
Messages
4
Hello

I have tried and tried but just cant get this to work. I have a feeling that im so close but have just been missing some critical point.

Im Taking data from our SQL with Dynamics NAV. Works perfect :)

I have a table "Jobs" like the example below. The Column "Exits Related cases" is the field i want calculated - in NAV its a Flowfield so it doesnt come out in my export from the base.

I would like to have a Function that can check whether a Job is related to other Jobs in the same table.

I have tried the following: = if(COUNTAX(Jobs;filter(Jobs;Jobs[Job_No]=[Main_Job]))>0;True;False)
And =CALCULATE(COUNTA(Jobs[Job_No]);Jobs[Main_Job]=[Job_No])

But i just get errors or Blank.

An example from our Jobs Table:
job nonamesales CostMain jobExist related cases
10Job 11008020
FALSE
11Job 21109030FALSE
12Job 312010020FALSE
13Job 413011030FALSE
14Job 514012020FALSE
15Job 6150130FALSE
20Jobs NorthTrue
30Jobs SouthTrue

<colgroup><col><col span="4"><col></colgroup><tbody>
</tbody>

Best Regards and thx for a freat forum.

Rasmus
-Denmark

PS - does anyone know why my formulas need Semicolon instead of comma bettwen function arguments? Is it a regional setting?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Rasmus, you are pretty close! Try this:

Code:
=CALCULATE(
      COUNT(jobs[job no]), 
           FILTER(jobs,
                 jobs[Main job]=EARLIER(jobs[job no])
                     )
            )

The syntax for calculated columns can be a little tricky, EARLIER() is slightly difficult to understand but in simple terms such as this it returns the item from the row you are in (technically its the previous row context hence the name).

The ; thing is regional!
 
Upvote 0
Hi Jacob

Fantastic, your advice made it work. Thank you very much.

I was so close but still far away.... Earlier() function now put in the black book. :)

Best regards
Rasmus
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,487
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top