This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Hello,
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
to
Apple Orange Grapes
1 5 null null
2 null 7 null
3 null null 3
4... etc.
5
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?
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
let
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)
in
#"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
@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 https://www.sqlbi.com/blog/marco/2020/07/15/creating-calculation-groups-in-power-bi-desktop/
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 31 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 66 | |
| 56 | |
| 31 | |
| 26 | |
| 23 |