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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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