Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Does anyone know how I would write this in M (or dax)?
IF(AND([Course Complete Date] <>"",[Course Complete Date]>[Due Date],"No",
IF(AND([Course Complete Date]<>"",[Course Complete Date]<[Due Date],"Yes",
IF(AND(ISBLANK([Course Complete Date],[Due Date]<TODAY()),"Overdue","Pending")))
Solved! Go to Solution.
Ok, try this, but this still isn't right.
if [Course Complete Date] <> null then
if [Course Complete Date] > [Reg Date] then "No"
else if [Course Complete Date] < [Reg Date] then "Yes" else null
else if [Course Complete Date] = null then
if [Reg Date] < DateTime.Date(DateTime.LocalNow()) then "Overdue" else null
else "Pending"
The problem is you have some dates where the reg date and completed date are the same. Are you wanting all of those to be pending? If so, change to :
if [Course Complete Date] <> null then
if [Course Complete Date] > [Reg Date] then "No"
else if [Course Complete Date] < [Reg Date] then "Yes" else "Pending"
else if [Course Complete Date] = null then
if [Reg Date] < DateTime.Date(DateTime.LocalNow()) then "Overdue" else "Pending"
else "Pending"
The issue with the error seems to be you cannot test for null and another condition with an and operator, so I needed to split the logic into even more nested if statements.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingTry this:
if [Course Complete Date] <>"" and [Course Complete Date]>[Due Date] then "No"
else if [Course Complete Date]<>"" and [Course Complete Date]<[Due Date] then "Yes"
else if [Course Complete Date] = null and [Due Date]<DateTime.LocalNow() then "Overdue"
else "Pending"
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCLick on the white space next to the word "error" and tell us what the error is. It will show up in yellow at the bottom.
If you could provide sample data that would really help as we are all just guessing. Screenshots are fine for expected results, but pretty useless for actually examining and testing data.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingOk, try this, but this still isn't right.
if [Course Complete Date] <> null then
if [Course Complete Date] > [Reg Date] then "No"
else if [Course Complete Date] < [Reg Date] then "Yes" else null
else if [Course Complete Date] = null then
if [Reg Date] < DateTime.Date(DateTime.LocalNow()) then "Overdue" else null
else "Pending"
The problem is you have some dates where the reg date and completed date are the same. Are you wanting all of those to be pending? If so, change to :
if [Course Complete Date] <> null then
if [Course Complete Date] > [Reg Date] then "No"
else if [Course Complete Date] < [Reg Date] then "Yes" else "Pending"
else if [Course Complete Date] = null then
if [Reg Date] < DateTime.Date(DateTime.LocalNow()) then "Overdue" else "Pending"
else "Pending"
The issue with the error seems to be you cannot test for null and another condition with an and operator, so I needed to split the logic into even more nested if statements.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThank you to everyone that help solve this!!! Such an amazing community!
glad to have assisted with your project @bcbuckley13 !
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingDoes this work? I've never shared a file here.
https://drive.google.com/file/d/1iCbcxGV14Az3xAWVUV4BgLHaJ6W5dsuC/view?usp=sharing
That code should work in DAX with minimal changes although I would recommend using SWITCH(TRUE()...) instead of nested IF statements.
M code is going to be something like:
if [Course Complete Date] <>"" and [Course Complete Date]>[Due Date] then "No" else if [Course Complete Date]<>"" and [Course Complete Date]<[Due Date] then "Yes" else if [Course Complete Date] <>"" and [Due Date] < DateTime.LocalNow() then "Overdue" else "Pending"
@Greg_Deckler Thank you. However, I got the dredded Null error from the blank Course Completed date column.
Hi @bcbuckley13 ,
Use Greg's code, but instead of using <>"" use <> null
Pete
Proud to be a Datanaut!
@BA_PeteThank you. That fixed the error, but for that cell that says Pending, that one should be Overdue.
Replace "Pending" by "Overdue" and vice versa.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook