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
cristianj
Helper IV
Helper IV

what am i doing wrong with sumx

i use this script and it works : 

cristianj_0-1683711531764.png

now i am trying to use a sumx function

TestTopN = var DataCurent=date(2023,5,2)
Var ModelCurent="iPhone 11"
var ShapeCurent="EXCELENT"
var StorageCurent="128 GB"
Var TabTemp=SELECTCOLUMNS(filter(VanzareZilnica,VanzareZilnica[Date]>=DataCurent-30&&VanzareZilnica[Date]<=DataCurent-1&&VanzareZilnica[model]=ModelCurent&&VanzareZilnica[shape]=ShapeCurent&&VanzareZilnica[storage]=StorageCurent),"Model",VanzareZilnica[model],"Storage",VanzareZilnica[storage],"Shape",VanzareZilnica[shape],"Data",VanzareZilnica[Date].[Date],"Vanz Zilnica",VanzareZilnica[Vanz Zilnica])
var tabtest=TOPN(5,TabTemp,[Vanz Zilnica],DESC)
var tabtest2=calculate(SUMX(tabtest,[Vanz Zilnica]))
return tabtest2
cristianj_1-1683712068414.png

it gave me an error

thank you

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@cristianj , try like a measure

 

TestTopN =
VAR DataCurent =
DATE ( 2023, 5, 2 )
VAR ModelCurent = "iPhone 11"
VAR ShapeCurent = "EXCELENT"
VAR StorageCurent = "128 GB"
VAR TabTemp =
SELECTCOLUMNS (
FILTER (
VanzareZilnica,
VanzareZilnica[Date] >= DataCurent - 30
&& VanzareZilnica[Date] <= DataCurent - 1
&& VanzareZilnica[model] = ModelCurent
&& VanzareZilnica[shape] = ShapeCurent
&& VanzareZilnica[storage] = StorageCurent
),
"Model", VanzareZilnica[model],
"Storage", VanzareZilnica[storage],
"Shape", VanzareZilnica[shape],
"Data", VanzareZilnica[Date].[Date],
"Vanz Zilnica", VanzareZilnica[Vanz Zilnica]
)
VAR tabtest2 =
CALCULATE ( SUMX ( KEEPFILTERS(TOPN ( 5, TabTemp, [Vanz Zilnica], DESC )), [Vanz Zilnica] ) )
RETURN
tabtest2

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

@cristianj , try like a measure

 

TestTopN =
VAR DataCurent =
DATE ( 2023, 5, 2 )
VAR ModelCurent = "iPhone 11"
VAR ShapeCurent = "EXCELENT"
VAR StorageCurent = "128 GB"
VAR TabTemp =
SELECTCOLUMNS (
FILTER (
VanzareZilnica,
VanzareZilnica[Date] >= DataCurent - 30
&& VanzareZilnica[Date] <= DataCurent - 1
&& VanzareZilnica[model] = ModelCurent
&& VanzareZilnica[shape] = ShapeCurent
&& VanzareZilnica[storage] = StorageCurent
),
"Model", VanzareZilnica[model],
"Storage", VanzareZilnica[storage],
"Shape", VanzareZilnica[shape],
"Data", VanzareZilnica[Date].[Date],
"Vanz Zilnica", VanzareZilnica[Vanz Zilnica]
)
VAR tabtest2 =
CALCULATE ( SUMX ( KEEPFILTERS(TOPN ( 5, TabTemp, [Vanz Zilnica], DESC )), [Vanz Zilnica] ) )
RETURN
tabtest2

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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