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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ItSupportElm
Helper III
Helper III

Power Query to DAX

Hello,

 

Im not confortable with DAX , someone can tell me how to translate this : " if Date.From([DateCreation]) > Date.From(Date.AddDays(DateTime.LocalNow(),-2)) then 0 else 1)" to DAX please ? i tried so many thing but it didnt worked.

 

Thanks for the future answer, great day

2 ACCEPTED SOLUTIONS
dax
Community Support
Community Support

Hi ItSupportElm,

You could follow above suggestions. If you want to create calculated column, you could try below expression 

Column = if('Table'[date]>TODAY()-2,0,1)

If you want to use measure, you could try below expression

Measure 2 = if(MIN('Table'[date])>TODAY()-2,0,1)

 

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks for the answer guys.

 

@dax i tried your expression but there is an error at the end :  2019-11-25_15h13_48.png ( i thought that was ";" but is not that neither)

 

Same for a new colomn : 

2019-11-25_15h16_05.png

 

Thanks again for helping me

 

 

I found out why it not work, 

 

Column = IF('Alerte'[DateCreation]>TODAY()-2;"Inférieur à 48H";"Supérieur à 48H") we must seprate with ";" 
Thanks again !

 

View solution in original post

3 REPLIES 3
dax
Community Support
Community Support

Hi ItSupportElm,

You could follow above suggestions. If you want to create calculated column, you could try below expression 

Column = if('Table'[date]>TODAY()-2,0,1)

If you want to use measure, you could try below expression

Measure 2 = if(MIN('Table'[date])>TODAY()-2,0,1)

 

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the answer guys.

 

@dax i tried your expression but there is an error at the end :  2019-11-25_15h13_48.png ( i thought that was ";" but is not that neither)

 

Same for a new colomn : 

2019-11-25_15h16_05.png

 

Thanks again for helping me

 

 

I found out why it not work, 

 

Column = IF('Alerte'[DateCreation]>TODAY()-2;"Inférieur à 48H";"Supérieur à 48H") we must seprate with ";" 
Thanks again !

 

Anonymous
Not applicable

Hi,

 

It would be something like this. Assuming you`re adding a calculated columns and not creating a measure.

 

In the table you want to add the column, create a new calculated column and type this.

 

if ( TableName[Date Field] > DATEADD ( TODAY(); -2; Days) ; 0 ; 1)

 

You may need to adjust some naming but the overall idea is this.

 

Hope it helps

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.