0
votes

I have a measure whereby I calculate some data based on a slicer value. The slicer determines which table I get my data from e.g. SUM(TableA[sales]) or SUM(TableB[sales]). (Each of my tables is of the same structure).

I'd like to be able to set up a variable to dynamically change (with my slicer) which table I'm referring to.

Right now I have:

// Set __table to a stored string representation of the name of the database
// This seems to work
VAR __table = SELECTEDVALUE( AllTables[TableNames] )

// Evaluate the sales column of my variable table
// This doesn't work due to 'Cannot find name sales'
CALCULATE(SUM(__table[sales]))     

I guess what I'm after is a way to have the slicer change the referenced table in my measures (with all of the columns being the same for each table).

I'm new to Power BI and I've been struggling with this for several days now. I'd really appreciate any help with either the method I'm attempting or any alternatives.

I don't think there's a way to do exactly what you're after but you don't usually need to do this with a good model. Why do you need to switch among tables and approximately how many tables are you trying to switch between?Alexis Olson
@AlexisOlson Hi, could be up to about 20 tables. It's for data gathered from devices in different places around an office, where each device is imported as its own table. The user can then switch between seeing the data from the different data tables on their views by using a slicer.125125