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
AlexGallet01
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
v-piga-msft
Resident Rockstar
Resident Rockstar

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.

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

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