cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

I don't understand how i can use a variable in text

Hello,

 

I don't understand why i have an error message when i try to use a variable in text. 

 

Test Montant CDE Cumulé = TOTALYTD(sum(Commande[CDE €]);'Date'[Date];"31/"+Month(TODAY())-1)

 

Can you help me please.

3 REPLIES 3
Highlighted
Resident Rockstar
Resident Rockstar

Re: I don't understand how i can use a variable in text

Hi  @AlexGallet01,

 

Could you specdify your scenario and show the error message?

 

In addition, you could have a look at the syntax of VAR function and how to use it.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper IV
Helper IV

Re: I don't understand how i can use a variable in text

Hi @v-piga-msft,

 

I want to use this unction for calculate a percentage but for that i need to insert into this calculate just the months who are finished. So i want to delete the month of the day for have a just calculate.

 

My error message is on the true / false exception or i don't use this functionnality in my function.

 

I try to use the Var function and when i use it i have the same error of last.

 

Test Montant CDE Cumulé = var moisencours = MONTH(TODAY())-1 return TOTALYTD(sum(Commande[CDE €]);'Date'[Date];"31/"&moisencours)

 

Best regards

Highlighted
Resident Rockstar
Resident Rockstar

Re: I don't understand how i can use a variable in text

Hi  @AlexGallet01,

 

 

By my test, we may not write the dax TOTALYTD like "31/"&moisencours, there is syntax error.  The year-end date should be a literal string with a date.

 

There is another way to achieve your desired output.

 

Assuming you have a calender table then you need to create a calculated column.

 

monthday = DATE(YEAR('Table'[Date]),MONTH(TODAY())-1,31)

Then you could modify your measure like below and create another measure to achieve the ytd to "31/month(today())-1".

 

Measure = TOTALYTD(SUM(Table1[Sales]),'Table'[Date],ALL('Table'[Date]))

Measure 2 = IF(MAX('Table'[Date])<=MAX('Table'[monthday]),[Measure],BLANK())

Here is the test result.

 

Capture.PNG

 

For more details, you could have a reference of the file attached below.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors