Forum Discussion
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
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
4 Replies
- WatskySolution 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- RupilasNew Member
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- RupilasNew Member
Now I solved it It was one bracket too much, Many thanks to you!!!!