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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
PowerBITestingG
Resolver I
Resolver I

Dynamic Variable in Measure

Hi all,

 

I have the following dax measure = 

 

Spend YTD classic = 
VAR octoberstart1 = SWITCH(TRUE(),
[MaxOctoberStart]=10/03/2022,"10-03",
[MaxOctoberStart]=10/04/2021,"10-04","10-03")
return
TOTALYTD(Sales[US],Time[Date Dt],octoberstart1)

MaxOctoberStart=
CALCULATE (
    MAX ( Time[Fiscal Start Date] ),
    FILTER (
        ALL ( Time ),
        MD_Time[Fiscal Mnth No] = 10
            && MD_Time[Fiscal Yr Int] = MAX ( Sales[Fiscal Year] )
    )
)

 

 

But I get True/False expression does not specify a column error

 

I am simply trying to make the octoberstart1 variable change based on the fiscal start date for each october

 

Any ideas?

 

I would greatly appreciate it

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @PowerBITestingG ,

 

As @vojtechsima  said, are you able to provide test data, as no further testing can be done based on the formula you provided alone.

How to Get Your Question Answered Quickly - Microsoft Power BI Community


Looking forward to your reply.


Best Regards,
Henry

 

Sadly, its not possible to use dynamic variables in YTD functions

vojtechsima
Super User
Super User

Hi, @PowerBITestingG 
I think here is the problem:

VAR octoberstart1 = SWITCH(TRUE(),
[MaxOctoberStart]=10/03/2022,"10-03",
[MaxOctoberStart]=10/04/2021,"10-04","10-03")

The 10/03/2022 is probably not recognizable because it's not either string or number, so you have to wrap it with "" to make it a string and then make sure, that MaxOctoberStart returns a date in same format.
Or you can check against DATE function and fill it like this:

VAR octoberstart1 = SWITCH(TRUE(),
[MaxOctoberStart]=DATE(2022,3,10),"10-03",
[MaxOctoberStart]=DATE(2021,4,10),"10-04",
"10-03")





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Sadly it seems you cant use dynamic variables in ytd functions. Everything is so contrived in dax

@PowerBITestingG 
Can you share a copyable dataset in text form?
Just a sample that I Can test my analyses.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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