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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Helper III
Helper III

Column does not exist sometimes

I am facing a unique issue. 
Basically there is this error "Column in table cannot be found or may not be used in this expression".

Because in my query editor, I am pivoting a column as I want to break it down into diff types for example

1   Apple 5

2   Orange 7

3   Grapes 3
4   Grapes 3
5   Apple 1



    Apple Orange Grapes

1    5          null   null

2    null       7       null

3 null        null     3

4... etc.


However, sometimes there may not be any apples sold for instance. Then this pivoted column wouldn't exist. Then my calculation would have a problem because i sum the apples orange and grapes. But if apples as a column dont exist. I get that error.
Anyone knows how to circumvent this?

Resident Rockstar
Resident Rockstar

Hi @kitala11 


You are pivoting in Power Query Editor? Select the first two column, pivot the last column. Paste in Advanced Editor to see it



    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjy0QElH6dACx4KCnFQgy1QpVidayQgq6l+UmJcOEjYHCxtDhd2LEgtSi4FMY7CwCXZhUzSjDZViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}, {"Column3", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Column2]), "Column2", "Column3", List.Sum)
    #"Pivoted Column"


Hi, I don't think taht answers my question. Let me emphasise the key point so its more understandable. 



sometimes there may not be any apples sold for instance. Then this pivoted column wouldn't exist. There will not be a column called Apple to begin with if it doesn't exist as a record because no apple was sold. 

This is the problem I am trying to solve. My measures involves calculating the sum of apple grapes and orange. but if apples dont exist, the apple column wouldn't exist and my calculated measure would have an error

@kitala11 , One solution I was saying is not to unpivot. Just create measure like


Apple = Sumx(filter(Table, Table[fruit] ="Apple"), [Value])


Orange= Sumx(filter(Table, Table[fruit] ="Orange"), [Value])


but this means to much of measures, that is why I suggested to explore calculation groups, if they can help to reduce it

Super User
Super User

@kitala11 , In such a case it possible to use a matrix visual, fruit on the column.


There is another way, creating measures for each of them. See if calculation groups can help

Helpful resources

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.


Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.


Fabric certifications survey

Certification feedback opportunity for the community.