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 )

View solution in original post

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors