There are two main reasons why this does not work out of the box as intended.
As mentioned by Paul Stanley in the comments the field groups
is not a standard field and therefore not recognised by Biber. That means that the contents of the field groups
don't make it to the .bbl
file, which in turn means that biblatex
can not access its contents.
You would have to declare the groups
field as shown in Add field "tome" to biblatex entries
Secondly, and more seriously, with \iffieldequalstr{<field>}{<string>}
you only compare the (entire) contents of the field <field>
to the string <string>
. That means that \iffieldequalstr{groups}{Group1}
yields false when groups is groups = {Group1,Group2},
. This is also alluded to in Paul Stanley's comment.
Like gusbrs and Paul Stanley I recommend you look into keywords
as that field was intended to filter entries into groups.
\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
keywords = {Group1,Group2},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
keywords = {Group1},
}
@misc{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
keywords = {Group2},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography[keyword=Group1]
\end{document}
If you have already populated hundreds of entries with groups
instead of keywords
you can use Biber to remap the fields.
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\step[fieldsource=groups, final]
\step[fieldset=keywords, fieldvalue={,}, append]
\step[fieldset=keywords, origfieldval, append]
\step[fieldsource=keywords, match=\regexp{\A,}, replace={}]
}
}
}
edit This now uses gusbrs' method from \DeclareSourceMap does not work to avoid a leading comma without an item.
If for some reason you are wedded to the idea of a groups
field and don't want to involve keywords
at all, here is a crude implementation of a test that loops over a field with comma-separated values and checks if Group1
is contained as list element in the groups
field.
\documentclass{article}
\usepackage{filecontents}
% make the groups field known to biblatex
\begin{filecontents*}{groups.dbx}
\DeclareDatamodelFields[type=field,datatype=literal]{groups}
\DeclareDatamodelEntryfields{groups}
\end{filecontents*}
\usepackage[style=authoryear,backend=biber,datamodel=groups]{biblatex}
% traverse the groups field to find a match
\makeatletter
\newtoggle{bastianblx@isgroup}
\newcommand*{\bastianblx@ifmatch}[2]{%
\ifstrequal{#1}{#2}
{\toggletrue{bastianblx@isgroup}\listbreak}
{}}
% switch the order of the arguments for easier \expandafter work
\newcommand*{\bastian@forcsvlist}[2]{%
\forcsvlist{#2}{#1}}
\defbibcheck{Group1}{%
\togglefalse{bastianblx@isgroup}%
% 31 \expandafters for five levels of expansion
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter
\bastian@forcsvlist
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter\expandafter
\expandafter
{\thefield{groups}}{\bastianblx@ifmatch{Group1}}%
\iftoggle{bastianblx@isgroup}{}{\skipentry}%
}
\makeatother
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
groups = {Group1,Group2},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
groups = {Group1},
}
@misc{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
groups = {Group2},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography[check=Group1]
\end{document}
All solutions show

keyword
to filter? I'm afraid I don't have time this morning to fiddle.keyword
s, except if there are unstated special requirements.groups
has been introduced by JabRef to allow for explicit grouping of entries: docs.jabref.org/finding-sorting-and-cleaning-entries/groups - The development team decided against a reuse of "keywords" as there was a strong opinion to keep "keywords" as specified by the author of the paper. Thus, they must not be modified.