Forum Discussion

EpicTriffid's avatar
EpicTriffid
Helper IV
4 years ago

LOOKUPVALUE on virtual table

Hi all,

 

So I'm attempting to summarize a table of teaching units down to department level, to then get an average of the total unit hours per department that each unit within that department can be compared against. I've currently got it working on two calculated tables, with one being my unit table and one being a summarised unit table that is at department level. But I'd like it to be in one table if possible, so am attempting to make the department level summary into a virtual table, as it's not really used elsewhere. But in then using the same Lookup logic as it did when it was two physical tables, it doesn't like referencing the virtual table. Is there any way around this?

 

VAR deptSum=

ADDCOLUMNS(
    SUMMARIZE(
        'Table', 
        'Table'[Department], 'Table'[Academic Year],
        "Totalled", SUM('Table'[Total Unit Hours]),
        "Count of Units", DISTINCTCOUNT('Table'[Unit Code])),
    "Average", [Totalled]/[Count of Units])

VAR unitAvg = 
LOOKUPVALUE(
    deptSum[Average],
    deptSum'[Department], 'Table'[Department], 
    deptSum[Academic Year], 'Table'[Academic Year])

 

3 Replies

  • EpicTriffid , You data is already grouped 'Table'[Department], 'Table'[Academic Year] , so not sure what value add lookup can do

     

    You can try like 

    VAR unitAvg =

    calculate(AverageX(DeptSum,[Avergae]), allexcept(DeptSum,DeptSum[Department],DeptSum[Academic Year])

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Community Support

    Hi, EpicTriffid 

     

    The code you provided is incomplete, and I can't see what you want in the end.

    Can you share some sample data(Without sensitive data) or a sample file and your desired result and the calculation logic? Maybe I can help you re-plan a new measure or column.

     

    Best Regards,

    Community Support Team _ Janey