Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Joepower
Frequent Visitor

Mysteriöse Fehlermeldung bei DAX-Code

Folgende Fehlermeldung von PowerBI Desktop bei diesem Code:

Der Ausdruck verweist auf mehrere Spalten. Mehrere Spalten können nicht in einen skalaren Wert konvertiert werden.

Im DAX Studio funktioniert der Code einwandfrei.

Tabellennamen und -spalten sind o.k, es gibt keinen weiteren Kontext bzw. Beziehungen.

 

Tabelle =

VAR FullTable =
    SUMMARIZE(
        DeineTabelle,
        DeineTabelle[Land],
        "ID",
        DISTINCTCOUNT(
            DeineTabelle[ID]
        )
    )
    RETURN FullTable
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

See attached

 

lbendlin_0-1692974485636.png

 

View solution in original post

9 REPLIES 9
lbendlin
Super User
Super User

See attached

 

lbendlin_0-1692974485636.png

 

Thank you very much. That was very helpful. With the tables generated, I can now modify the measure to get the result I want.

Joepower
Frequent Visitor

This is the main-table "Deine Tabelle"

LandID
Australien55
Australien56
Australien57
Australien58
Australien59
Australien60
Australien61
Australien62
Australien63
Australien64
China66
China95
China11
Deutschland34
Deutschland19
Deutschland44
Deutschland63
Großbritannien50
Spanien45
Spanien89
Spanien14
Spanien33
Spanien67
USA1
USA2
USA3
USA4
USA5
USA6
USA7
USA8
USA9
USA10
USA11
USA12
USA13
USA14
USA15
USA16
USA17
USA18
USA19
USA20
USA21
USA22
USA23
USA24
USA25
USA26
USA27
USA28
USA29
USA30

 

This is the table for selecting the number of TopN "AuswahlTopN":

TopNumber
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Joepower
Frequent Visitor

I don't know how to submit a pbix-file on this platform.

Here is the full code:

The result is a table with TopN grouped by "Land", ordered by "ID", sum of TopN, "others" and total sum.

 

Ergebnis = 

VAR Auswahl =
	IF(
		HASONEVALUE(
			AuswahlTopN[TopNumber]),
		SELECTEDVALUE(AuswahlTopN[TopNumber]),
		3)

VAR FullTable =
    SUMMARIZE(
        DeineTabelle,
        DeineTabelle[Land],
        "ID",
        DISTINCTCOUNT(
            DeineTabelle[ID]
        )
    )

VAR TopTable =
    SUMMARIZE(
        TOPN(
            Auswahl,
            SUMMARIZE(
                DeineTabelle,
                DeineTabelle[Land],
                "ID",
                DISTINCTCOUNT(
                    DeineTabelle[ID]
                )
            ),
            [ID],
            DESC
        ),
        DeineTabelle[Land],
        "ID",
        DISTINCTCOUNT(
            DeineTabelle[ID]
        )
    )
   
VAR toptableranked = ADDCOLUMNS(TopTable, "Pos", RANKX(TopTable, [ID]))
	
VAR RestTable =
    EXCEPT(
        FullTable,
        TopTable
    )

VAR ToppoDistinctCount =
    SUMX(
        TopTable,
        [ID]
    )

VAR ToppoRow =
    ADDCOLUMNS(
        ROW("Land", "TopN", "IDValue", ToppoDistinctCount,"Pos", Auswahl+1),
        "Source", "TopN"
    )

VAR RestDistinctCount =
    SUMX(
        RestTable,
        [ID]
    )

VAR RestRow =
    ADDCOLUMNS(
        ROW("Land", "Rest", "IDValue", RestDistinctCount,"Pos", Auswahl+2),
        "Source", "Rest"
    )

VAR GesamtDistinctCount =
    SUMX(
        FullTable,
        [ID]
    )

VAR GesamtRow =
    ADDCOLUMNS(
        ROW("Land", "Gesamt", "IDValue", GesamtDistinctCount,"Pos", Auswahl+3),
        "Source", "Gesamt"
    )

VAR CombinedTable =
    UNION(
        ADDCOLUMNS(TopTableranked, "Source", "TopTable"),
                ToppoRow,
                RestRow,
                GesamtRow
    )

RETURN CombinedTable

  

You cannot create calculated columns or calculated tables from measures.

lbendlin
Super User
Super User

Most likely you specified "Tabelle"  as a calculated column rather than a calculated table.

Thank your for your answer.

"Tabelle" is specified as a calculated table.

The code is working with "Dax Studio" without any problems, but with "PowerBi" I am getting the errorcode as i mentioned above.

please provide a sample pbix file that illustrates the issue.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.