cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PatrickByGecko
Resolver I
Resolver I

Date problems

 

 

 

Hello Folks

I get a problem with dates comparison or conversion (I don't know).

On the dax result panel underneath it is said that it is impossible to convert "avril" from txt to integer.

 

TravailRefrenceMensuelle =
var _NBJoursMois = if (format(DateProjet[Dates],"mmmm")="avril" || format(DateProjet[Dates],"mmmm")="juin"|| format(DateProjet[Dates],"mmmm")="septembre" || format(DateProjet[Dates],"mmmm")="novembre", 30 , if (format(DateProjet[Dates],"mmmm")="février", 28, 31))
var _DateDebutMois = DATE( DateProjet[Dates].[Année], DateProjet[Dates].[Mois], 1)
var _DateFinMois = if (format(DateProjet[Dates],"mmmm")="avril" || format(DateProjet[Dates],"mmmm")="juin"|| format(DateProjet[Dates],"mmmm")="septembre" || format(DateProjet[Dates],"mmmm")="novembre", DATE( DateProjet[Dates].[Année], DateProjet[Dates].[Mois], 30) , if (format(DateProjet[Dates],"mmmm")="février", DATE( DateProjet[Dates].[Année], DateProjet[Dates].[Mois], 28), DATE( DateProjet[Dates].[Année], DateProjet[Dates].[Mois], 31)))
Return
// On vient recréer ci-dessous le nombre de jours de travail de référence du mois selon les débuts et fins de tâches
if (DateProjet[Debut de reference] > _DateFinMois, 0,
if (DateProjet[Debut de reference] < _DateDebutMois && DateProjet[Fin de reference] < _DateDebutMois,0,
if (DateProjet[Debut de reference] < _DateDebutMois && DateProjet[Fin de reference] > _DateFinMois, DateProjet[TravailJRreference] * _NBJoursMois,0
)))

PowerBiError.jpg

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I can't tell what the problem is but you can make the definitions simpler by taking advantage of EOMONTH.

VAR _DateDebutMois = EOMONTH ( DateProjet[Dates], -1 ) + 1
VAR _DateFinMois = EOMONTH ( DateProjet[Dates], 0 )
VAR _NBJoursMois = DAY ( _DateFinMois )

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

I can't tell what the problem is but you can make the definitions simpler by taking advantage of EOMONTH.

VAR _DateDebutMois = EOMONTH ( DateProjet[Dates], -1 ) + 1
VAR _DateFinMois = EOMONTH ( DateProjet[Dates], 0 )
VAR _NBJoursMois = DAY ( _DateFinMois )

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!