TabularEditor / TabularEditor3

Bug reports, feature requests, discussion and documentation for Tabular Editor 3 (commercial version).
61 stars 7 forks source link

Possible Bug: Query Output Unusable, Cannot be Debugged #1168

Closed fleetteamSD closed 6 months ago

fleetteamSD commented 6 months ago

Description

I have been using Tabular Editor for debugging issues with visuals. The way I usually do it is to copy the query from Performance Analyzer, running it, and then debugging the results in Tabular Editor. However, this time, with a particular donut visual, I get a non-sensical output: a table with one row, all of the headers say something like [DS0IntersectionCount] or [DS0PrimaryCount], and nothing can be debugged.

I cannot rule out that this is simply related to this visual, but I have no idea how to change the query to get any results to show up.

Tabular Editor 3 Version

3.11.0.26496

Screenshots

image

Steps to Reproduce

`// DAX Query
DEFINE
    VAR __DS0FilterTable = 
        FILTER(
            KEEPFILTERS(VALUES('Insight'[Finding_Category__c])),
            NOT('Insight'[Finding_Category__c] IN {"Asset Specific"})
        )

    VAR __DS0FilterTable2 = 
        FILTER(
            KEEPFILTERS(VALUES('02 Dates'[Date])),
            AND('02 Dates'[Date] >= DATE(2023, 7, 1), '02 Dates'[Date] < DATE(2023, 10, 1))
        )

    VAR __DS0FilterTable3 = 
        TREATAS({"ADS Harrisonville MO/General"}, 'Insight'[Location])

    VAR __SQDS0Core = 
        SUMMARIZECOLUMNS(
            'Insight'[Name],
            __DS0FilterTable,
            __DS0FilterTable2,
            __DS0FilterTable3,
            "SumTotal_Cost_Impact__c", CALCULATE(SUM('Insight'[Total_Cost_Impact__c]))
        )

    VAR __SQDS0BodyLimited = 
        TOPN(10, __SQDS0Core, [SumTotal_Cost_Impact__c], 0)

    VAR __DS0Core = 
        SUMMARIZECOLUMNS(
            'Insight'[Finding_Category__c],
            ROLLUPADDISSUBTOTAL('Insight'[Name], "IsGrandTotalColumnTotal"),
            __DS0FilterTable,
            __DS0FilterTable2,
            __DS0FilterTable3,
            __SQDS0BodyLimited,
            "Last_12_Months_Total_Cost_Impact", '01 Measures'[Last 12 Months Total Cost Impact],
            "Last_12_Months_Total_Repairs", IGNORE('01 Measures'[Last 12 Months Total Repairs])
        )

    VAR __DS0CoreOnlyOutputTotals = 
        SELECTCOLUMNS(
            KEEPFILTERS(FILTER(KEEPFILTERS(__DS0Core), [IsGrandTotalColumnTotal] = FALSE)),
            "'Insight'[Finding_Category__c]", 'Insight'[Finding_Category__c],
            "'Insight'[Name]", 'Insight'[Name],
            "Last_12_Months_Total_Cost_Impact", [Last_12_Months_Total_Cost_Impact],
            "Last_12_Months_Total_Repairs", [Last_12_Months_Total_Repairs]
        )

    VAR __DS0PrimaryBase = 
        SUMMARIZE(__DS0Core, 'Insight'[Finding_Category__c])

    VAR __DS0CoreTableByDM1 = 
        SELECTCOLUMNS(
            KEEPFILTERS(FILTER(KEEPFILTERS(__DS0Core), [IsGrandTotalColumnTotal] = TRUE)),
            "'Insight'[Finding_Category__c]", 'Insight'[Finding_Category__c],
            "SortBy_DM1_0", [Last_12_Months_Total_Cost_Impact]
        )

    VAR __DS0PrimaryWithSortColumns = 
        NATURALLEFTOUTERJOIN(
            __DS0PrimaryBase,
            __DS0CoreTableByDM1
        )

    VAR __DS0SecondaryBase = 
        SUMMARIZE(__DS0CoreOnlyOutputTotals, 'Insight'[Name])

    VAR __DS0IntersectionCount = CALCULATE(COUNTROWS(__DS0CoreOnlyOutputTotals))

    VAR __DS0PrimaryCount = CALCULATE(COUNTROWS(__DS0PrimaryWithSortColumns))

    VAR __DS0SecondaryCount = CALCULATE(COUNTROWS(__DS0SecondaryBase))

    VAR __DS0SpaceCount = (__DS0PrimaryCount * __DS0SecondaryCount)

    VAR __DS0SparseFactor = MIN(5, DIVIDE(__DS0SpaceCount, __DS0IntersectionCount))

    VAR __DS0TargetIntersectionCount = CEILING(1000 * __DS0SparseFactor, 1)

    VAR __DS0InitTargetPrimaryCount = 
        IF(
            __DS0IntersectionCount <= 1000,
            IF(
                __DS0SpaceCount <= __DS0TargetIntersectionCount,
                1000,
                FLOOR(
                    SQRT(__DS0TargetIntersectionCount * DIVIDE(__DS0PrimaryCount, __DS0SecondaryCount)),
                    1
                )
            ),
            IF(
                AND(__DS0PrimaryCount > 500, __DS0SecondaryCount > 60),
                CEILING(DIVIDE(__DS0TargetIntersectionCount, 60), 1),
                IF(
                    __DS0SecondaryCount > 60,
                    __DS0PrimaryCount,
                    CEILING(DIVIDE(__DS0TargetIntersectionCount, __DS0SecondaryCount), 1)
                )
            )
        )

    VAR __DS0InitTargetSecondaryCount = 
        IF(
            __DS0IntersectionCount <= 1000,
            IF(
                __DS0SpaceCount <= __DS0TargetIntersectionCount,
                1000,
                FLOOR(
                    DIVIDE(__DS0TargetIntersectionCount, FLOOR(
                        SQRT(__DS0TargetIntersectionCount * DIVIDE(__DS0PrimaryCount, __DS0SecondaryCount)),
                        1
                    )),
                    1
                )
            ),
            IF(
                AND(__DS0PrimaryCount > 500, __DS0SecondaryCount > 60),
                60,
                IF(
                    __DS0SecondaryCount > 60,
                    CEILING(DIVIDE(__DS0TargetIntersectionCount, __DS0PrimaryCount), 1),
                    __DS0SecondaryCount
                )
            )
        )

    VAR __DS0MinPrimaryCount = MIN(10, __DS0PrimaryCount)

    VAR __DS0MinSecondaryCount = MIN(10, __DS0SecondaryCount)

    VAR __DS0TargetPrimaryCount = 
        IF(
            __DS0InitTargetPrimaryCount < __DS0MinPrimaryCount,
            __DS0MinPrimaryCount,
            IF(
                __DS0InitTargetSecondaryCount < __DS0MinSecondaryCount,
                CEILING(DIVIDE(__DS0TargetIntersectionCount, __DS0MinSecondaryCount), 1),
                __DS0InitTargetPrimaryCount
            )
        )

    VAR __DS0TargetSecondaryCount = 
        IF(
            __DS0InitTargetPrimaryCount < __DS0MinPrimaryCount,
            CEILING(DIVIDE(__DS0TargetIntersectionCount, __DS0MinPrimaryCount), 1),
            IF(
                __DS0InitTargetSecondaryCount < __DS0MinSecondaryCount,
                __DS0MinSecondaryCount,
                __DS0InitTargetSecondaryCount
            )
        )

    VAR __DS0Primary = 
        TOPN(
            __DS0TargetPrimaryCount + 1,
            __DS0PrimaryWithSortColumns,
            [SortBy_DM1_0],
            0,
            'Insight'[Finding_Category__c],
            1
        )

    VAR __DS0Secondary = 
        TOPN(__DS0TargetSecondaryCount + 1, __DS0SecondaryBase, 'Insight'[Name], 1)

    VAR __DS0BodyLimited = 
        NATURALLEFTOUTERJOIN(
            __DS0Primary,
            SUBSTITUTEWITHINDEX(
                __DS0CoreOnlyOutputTotals,
                "ColumnIndex",
                __DS0Secondary,
                'Insight'[Name],
                ASC
            )
        )

EVALUATE
    ROW(
        "DS0IntersectionCount", __DS0IntersectionCount,
        "DS0PrimaryCount", __DS0PrimaryCount,
        "DS0TargetPrimaryCount", __DS0TargetPrimaryCount,
        "DS0SecondaryCount", __DS0SecondaryCount,
        "DS0TargetSecondaryCount", __DS0TargetSecondaryCount
    )

EVALUATE
    __DS0Secondary

ORDER BY
    'Insight'[Name]

EVALUATE
    __DS0BodyLimited

ORDER BY
    [SortBy_DM1_0] DESC, 'Insight'[Finding_Category__c], [ColumnIndex]

Expected behavior

An output table that can be debugged.

Crash Report

No response

Windows Version

10

otykier commented 6 months ago

Power BI Desktop is notorious for generating some very ugly queries at times...

Note that this particular query returns multiple results (there are multiple EVALUATE statements). In this case, I think the 3rd result set contains the actual data that is shown in the donut chart, and from looking at the query, this result set should also work with the debugger.

You can switch between result sets using the numbered tabs on the left of the results grid:

image