If you want a variable report format, where parts of the report vanish when not needed, you must use nested queries. Or, get a nested query structure via script. That is, query efficiently with joins, then reformat into a new data key with nested keys programmatically. See this topic for the basic procedure: