Display LineNo Incase Total Number Of Delimiter Does matches in a given variable

I have many files .dat extension.

requirement is to display line no
if no of delimiter does not matches in a given variable

lets say

File: REF_BETOS.dat

HCPCS_OR_CPT_CODE~BETOS_CODE~TERMINATION_DATE
0001F~Z2~
0003T~I4~B20061231
0005F~Z2~~~
0008T~P8~B20061231
0008T~P8~B20061231~feess
00100~P0~

Delimiter=2

Output should display the filename and lineno

your help is appreciated

I am trying with statment
awk -F"$Delimiter" '{print NR NF-1}';

OutPut should look like

File Name Line No
REF_BETOS.dat 4
REF_BETOS.dat 6

awk -F'~' -v nd="$Delimiter" 'NF!=nd+1{print FILENAME, FNR}' *.dat

Hope it's not a homework assignment.