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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors