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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Ramachandran
Helper III
Helper III

Multiple column cannot converted into scalar value

Hi, I am trying to retrieve get topn sum of values using category on visual but I'm getting the error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."

 

For your reference, the code is below and I'm trying to get data from cube source

Sumof TopN values =
var ProductstoRank = 'TopN'[TopN Value]
var IsOtherSelected = SELECTEDVALUE('Source Product Category Name'[Product Category.Product Category]) = "Top Total"
var IsOtherSelectedPer = SELECTEDVALUE('Source Product Category Name'[Product Category.Product Category]) = "% of Total"
var ProductwithSalesAmt =
ADDCOLUMNS(
ALLSELECTED('Source Product Category Name'[Product Category.Product Category]),
"@Amt", 'SMI Data Miner'[GSMData]
)
var Top3Prods = TOPN(ProductstoRank, ProductwithSalesAmt, [@Amt])
var SalesofTop3 = SUMX(Top3Prods, [@Amt])

Return Top3Prods

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ramachandran , Try like

 

Sumof TopN values =
var ProductstoRank = 'TopN'[TopN Value]
var IsOtherSelected = SELECTEDVALUE('Source Product Category Name'[Product Category.Product Category]) = "Top Total"
var IsOtherSelectedPer = SELECTEDVALUE('Source Product Category Name'[Product Category.Product Category]) = "% of Total"
var ProductwithSalesAmt =
ADDCOLUMNS(
ALLSELECTED('Source Product Category Name'[Product Category.Product Category]),
"@Amt", 'SMI Data Miner'[GSMData]
)
var Top3Prods = TOPN(ProductstoRank, ProductwithSalesAmt, [@Amt])
var SalesofTop3 = calculate( SUMX(ProductwithSalesAmt, [@Amt]) ,TOPN(ProductstoRank, ProductwithSalesAmt, [@Amt]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Ramachandran , Try like

 

Sumof TopN values =
var ProductstoRank = 'TopN'[TopN Value]
var IsOtherSelected = SELECTEDVALUE('Source Product Category Name'[Product Category.Product Category]) = "Top Total"
var IsOtherSelectedPer = SELECTEDVALUE('Source Product Category Name'[Product Category.Product Category]) = "% of Total"
var ProductwithSalesAmt =
ADDCOLUMNS(
ALLSELECTED('Source Product Category Name'[Product Category.Product Category]),
"@Amt", 'SMI Data Miner'[GSMData]
)
var Top3Prods = TOPN(ProductstoRank, ProductwithSalesAmt, [@Amt])
var SalesofTop3 = calculate( SUMX(ProductwithSalesAmt, [@Amt]) ,TOPN(ProductstoRank, ProductwithSalesAmt, [@Amt]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors