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
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

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 June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors