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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX Help - Syntax incorrect - Set different DATESBETWEEN Variables

Hello! 

I'm having trouble with the Syntax for this measure:
DAX Q 3.PNG

Basically I want to the second filter in the CALCULATE+SUM function for Turnover1 (where I've highlighted yellow) to be changable, based upon the "TimePeriod" selected.

So when I select "YTD" in the Timeslice1 Slicer, it will use the appropriate "DATESBETWEEN" on the Calander table for YTD, when I've selected "YTG" it will use the "DATESBETWEEN" formula to filter the calander for YearToGo dates, etc.

I can make this work ok if I write multiple different variables for Turnover1 for each Timeframe but I'd prefer to have one variable where the Timeframe gets defined, which I can then plug into multiple different CALCULATE/SUM variables (As I will be building an entire P&L with many more Timeframes and CALCULATE/SUM Measures like this.

 

Hope that makes sense, any help really appreciated!

 

Thanks

 

Alex

 

 

1 REPLY 1
DataInsights
Super User
Super User

@Anonymous,

 

The SWITCH function returns a scalar value, but CALCULATE filter arguments are tables (hence the error). A better approach is calculation groups. You create them in Tabular Editor (free tool), which updates the tabular model in the pbix file. You could create two calculation groups: one for Actual Version, and one for Time Period.

 

https://www.sqlbi.com/articles/introducing-calculation-groups/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.