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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.