TabularEditor3 icon indicating copy to clipboard operation
TabularEditor3 copied to clipboard

False positive warning: Column references should always be fully qualified

Open GMedlin opened this issue 2 years ago • 1 comments

Describe the issue I'm receiving the following Tabular Editor Semantic Analysis warning message on several measures that reference a column that was added to a variable using ADDCOLUMNS & SUMMARIZE: Column reference should always be fully qualified.

This only occurs when the table expression I'm referencing uses UNION to append more than one variable's table expressions together and when one of them does not use ADDCOLUMNS. I would expect TE's syntax checker to be aware that if I UNION any table expression where I'm creating my own column with ADDCOLUMNS, then physical table reference is not needed for that column. Currently, it appears to be checking the first table expression in the UNION because the warning disappears if the first table in the UNION is the one using ADDCOLUMNS.

** Which version are you currently using? ** Tabular Editor 3, version: 3.11.0.26496 Tabular Editor 3 edition: Enterprise

To Reproduce Connect to Power BI dataset.

Create a measure similar to the one below. Confirm a warning message is displayed on line 38: [cfAmtActual], Column references should always be fully qualified. Notice that the warning goes away if you change the order of the table expression variables in the VAR _XIRRTable UNION.

VAR _MaxAsOfDate = MAX ( DimAsOfDate[asOfDateCode] )
VAR _PreviousAsOfDate = EOMONTH(_MaxAsOfDate, -15)
VAR _PriorCarryingValue =
    CALCULATETABLE (
        ADDCOLUMNS(
            SUMMARIZE (
                FactCashflows, 
                FactCashflows[dateCode],
                FactCashflows[dealCode]),
                "cfAmtActual", CALCULATE(SUM(FactCashflows[carryingValue])) * -1           
        ),
        DimCashFlowType[Cashflow Category] = "CV",
        DimDate[Date] = _PreviousAsOfDate
    )
VAR _CurrentCashFlowValues =
    CALCULATETABLE (
        SUMMARIZE (
            FactCashflows,
            FactCashflows[dateCode],
            FactCashflows[dealCode],
            FactCashflows[cfAmtActual]
        ),
        DimCashFlowType[Cashflow Category] IN {"Investments", "Realizations", "CV"},
        FILTER (
            ALL ( DimDate ),
            DimDate[Date] > _PreviousAsOfDate
                && DimDate[Date] <= _MaxAsOfDate
        )
    )
VAR _XIRRTable =
    UNION (
        _PriorCarryingValue,
        _CurrentCashFlowValues    
    )
VAR  _XIRR = 
    XIRR(
        _PriorCarryingValue,
        [cfAmtActual],
        FactCashflows[dateCode]
    )
RETURN
    _XIRR

Expected behavior I would expect no warning.

Screenshots Warning image No Warning image

Desktop (please complete the following information):

  • Windows version: 11

GMedlin avatar Oct 10 '23 18:10 GMedlin

Hmm, this is an interesting case. I tend to agree with you, but I would like to ask @marcosqlbi's opinion also.

The documentation for UNION says:

The returned table has lineage where possible. For example, if the first column of each Table has lineage to the same base column C1 in the model, the first column in the UNION result will have lineage to C1. However, if combined columns have lineage to different base columns, or if there is an extension column, the resulting column in UNION will have no lineage.

So in your case, the resulting expression should not have lineage to any base column, and therefore, we should not warn about a missing column reference regardless of the order of tables in UNION. For sure, if the has used a table prefix in the extension column, or if the output from UNION preserves lineage, then it makes sense to show the warning, in my opinion. But I don't think that applies in this case.

otykier avatar Oct 11 '23 08:10 otykier