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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Rupilas
New Member

VAR problem

Hi all,

 

I am a newby and tried the VAR Function. Has anyone an idea, why it doesnt work?

 

Thanks a lot

 

Martin

 

Sales Summary =
VAR SalesTableWithCustKey = Filter(-- Filter Table -- 'Fact Sale', -- Filter Condition --'Fact Sale'[Customer Key]>0)
VAR SalesTableGrouped = SUMMARIZE(-- Table to Summarize -- 'SalesTableWithCustKey','Fact Sale'[Customer Key],-- Aggregated Colum Name  Expression -- "Total Spend", SUM('Fact Sale'[Total Including Tax])
VAR SummaryTableFiltered = TOPN(-- Numbers of rows to return -- 10, -- Table to filter -- SalesTableGrouped, -- Order by Expression -- [Total Spend])
 RETURN SummaryTableFiltered
1 ACCEPTED SOLUTION
Watsky
Solution Sage
Solution Sage

Hi @Rupilas

It looks like you're commenting everything out. When you use an comment operator everything after the operator becomes a comment. Try using /*  to open and  */ to close the comment instead.

 

Sales Summary =
VAR SalesTableWithCustKey = Filter(/* Filter Table */ 'Fact Sale', /* Filter Condition */ 'Fact Sale'[Customer Key]>0)
VAR SalesTableGrouped = SUMMARIZE(/* Table to Summarize  */ 'SalesTableWithCustKey','Fact Sale'[Customer Key],/* Aggregated Colum Name  Expression */ "Total Spend", SUM('Fact Sale'[Total Including Tax])
VAR SummaryTableFiltered = TOPN(/* Numbers of rows to return */ 10, /* Table to filter */ SalesTableGrouped, /* Order by Expression */ [Total Spend])
 RETURN SummaryTableFiltered

 

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

View solution in original post

4 REPLIES 4
Watsky
Solution Sage
Solution Sage

Hi @Rupilas

It looks like you're commenting everything out. When you use an comment operator everything after the operator becomes a comment. Try using /*  to open and  */ to close the comment instead.

 

Sales Summary =
VAR SalesTableWithCustKey = Filter(/* Filter Table */ 'Fact Sale', /* Filter Condition */ 'Fact Sale'[Customer Key]>0)
VAR SalesTableGrouped = SUMMARIZE(/* Table to Summarize  */ 'SalesTableWithCustKey','Fact Sale'[Customer Key],/* Aggregated Colum Name  Expression */ "Total Spend", SUM('Fact Sale'[Total Including Tax])
VAR SummaryTableFiltered = TOPN(/* Numbers of rows to return */ 10, /* Table to filter */ SalesTableGrouped, /* Order by Expression */ [Total Spend])
 RETURN SummaryTableFiltered

 

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Hi Watsky,

 

many thanks for the quick answer

Somehow it still doesnt work.

Now I tried to do it without comments when I start to write VAR3 then it is red underlined and doesnt work.

Could you have another look?

 

Sales Summary =
VAR VAR1 = Filter('Fact Sale', 'Fact Sale'[Customer Key]>0)
VAR VAR2 = SUMMARIZE(VAR1, 'Fact Sale'[Customer Key], "Total Spend", SUM('Fact Sale'[Total Including Tax])
VAR VAR3 = TOPN(10, VAR2, [Total Spend])
RETURN VAR3

Now I solved it It was one bracket too much, Many thanks to you!!!!

@Rupilas 

Happy to Help! Glad you're good to go now.


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.