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.