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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.