Select JSON element with a space in the name i.e. "Case Notes"

If I reference any data element without a space, it works fine. I cannot figure out how to reference the ones with spaces in their names. 


This does not work:
select(@/*[name()="Case Notes"];,AND(@/Year;="2024", @/Team;="Program Men"))

This does work:
select(@/*[name()="Interactions"];,AND(@/Year;="2024", @/Team;="Program Men"))

How do I reference an element with a space in the name?


1 comment

  • Avatar
    Parker Selman Official comment

    Hi Wayne,

    Thanks for the post! 

    The way you're currently referencing the case notes field is fine - it's not actually the presence of that space that's causing your formulas to fail.

    The issue here is that the SELECT function you're using required the amount of records in the first term (IE Case Notes) to be exactly the same as the second term (IE the AND function). In your case, because not all of your records have case notes nodes attributed to them, the first term of your first SELECT function does not have the same number of records as the AND function and does not return accurate results. 

    Instead, I'd recommend using the kf:fill_elements function to do this, with the structure below:

    SELECT(@kf:fill_elements(/. , "Case Notes") , AND(@/Year;="2024", @/Team;="Program Men")) 

    This will properly align your case notes field to the number of records in your dataset, and should yield the proper output. 

    I hope this helps! 


Please sign in to leave a comment.