Support Table/Slice name as a variable


I would like to be able to pass in the table/slice name into the template as a variable, which can then be used in the select. (I have tried to use <<_APPNAME>> but it doesn’t work for me. I have also tried to set the <<_RULENAME>> to the table name but it doesn’t work in the select).

I currently have 3 slices which I use to produce reports. The slices are of 3 shifts. The reports are identical, except that I have to explicitly name the slice in the select statement in each report. It is not possible to pass in the table/slice name and use this table/slice name in the template. This means any changes to a template has to be done in all 3 templates. My app will later need to produce similar reports for different sites (up to 8), which will mean the number of templates will grow even further and make maintenance of the templates even harder.


With a SELECT expression in a Template or in general, you already shall use the tablename as per expression’s syntax. What’s the idea behind with using it as a variable?? Can you elaborate?


I mean in a template.

Here is my current select statement in my template “<<Start:OrderBy( Select(Night Shift 2200 0600[Id], OR([Level 2 count]>0,[Level 1 count]>0), TRUE),[Job No],TRUE)>>”

So instead of using “Night Shift 2200 0600[id]” I would like to use <<_TABLENAME>>[id] . Then I can reuse this template in many different reports. As I said above, my use case is for 3 shifts in 8 different sites, which means 24 different reports. If I could use <<_TABLENAME>>[id] then I would need only one template doc file, instead of 24.

Haven’t tried this before but you can construct one big expression in your template within the <<Start:>> expression and use it for all use cases:

	"TableA", SELECT(TableA[Key],{Y/N Condition}),
	"TableB", SELECT(TableB[Key],{Y/N Condition}),
	"TableC", SELECT(TableC[Key],{Y/N Condition}),
	SELECT(TableX[Key],{Y/N Condition})

this is definitely a work around. Thanks for this suggestion and I would go with this instead of my current solution, however <<_TABLENAME>> is not set when I test it. I tested <<_RULENAME>> which is set, so maybe I could use it, but I don’t understand why <<_TABLENAME>> is not working. Maybe a bug? Documentation says it should work.

1 Like