Forum Discussion

SilvioLunaPBI's avatar
SilvioLunaPBI
Frequent Visitor
5 years ago

Calculate count into calculaltetable

I have this code in dax, I need to be able to execute the code that is marked as "<-- ERROR", using the table variable.

var tb = CALCULATETABLE(
    SELECTCOLUMNS(RawData
    ,"service",RawData[Service]
    ,"period",RawData[StartOfPeriod_]
    ,"volume",RawData[Contact Volume]
    ,"position",RawData[Position]
    ))

var tb2 = CALCULATETABLE(
    SELECTCOLUMNS(tb
    ,"service",[service]
    ,"period",[period]
    ,"volume",[volume]
    ,"position",RANKX(FILTER(
        tb,
        [service] = EARLIER([service]) && 
        [period] = EARLIER([period])),[position],,ASC,Dense)
    ,"vendors",CALCULATE(COUNT([service]),ALLEXCEPT(tb,tb[StartOfPeriod_],tb[Service])) <-- ERROR
))

 

3 Replies