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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
BugmanJ
Helper V
Helper V

Not a valid function name?

Hello All,

Powerbi giving me the error "Select Slicer" is not a valid table, variable or function name.

Formula:

Slicer Selection = Var Select_Slicer = max(Datetable[Date].[Date])
Return
(CALCULATE (SUM([Total Sales]),'TableSales'[Day Date] > Select_Slicer()-8)) -
(CALCULATE (SUM([Total Sales]),'TableSales'[Day Date] = Select_Slicer()))/7
 
Idea:
Being that the above calculation calculates the last average of the the last 7 days of sales depending on the slicer date chosen
2 REPLIES 2
nvprasad
Solution Sage
Solution Sage

Hi BugmanJ,

 

Can you try below Dax

 

Slicer Selection = Var Select_Slicer = max(Datetable[Date].[Date])
Return
(CALCULATE (SUM([Total Sales]),'TableSales'[Day Date] > Select_Slicer-8)) -
(CALCULATE (SUM([Total Sales]),'TableSales'[Day Date] = Select_Slicer))/7

 

Appreciate a Kudos! ‌‌
If this helps and resolves the issue, please mark it as a Solution! ‌‌

Regards,
N V Durga Prasad

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.

Hi @nvprasad ,

This works but it brings a new problem. I have to use the original sales date rather then the Datetable I have linked to it.

So, the equation given gives the last 7 days of the slider, great! But if the store has closed and hasnt supplied data for say 5 months, its still calculating the last 7 days of that store. Any thoughts how I can get it to ignore and any inkling to whats wrong with using a datetable that works for everything else?

 

I tried to fix it, recreating the measure and used the Date table (Datetable[Date]) not Datetable[Date].[Date] (What is the . part for?) This creates the blanks, but now gives me the wrong numbers when moving the slider

Infact moving the slider i can see its ignoring the 7 days....

PowerbiSliding scale.PNG

So in short:
1) Works, but includes data from stores that closed months ago (this number doesnt move until that date is reached). Also have to use table date not datetable

2) If i try using datetable, it then ignores 7 days

Thanks

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.