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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
holeinone10
Frequent Visitor

SIMPLE IF BASED ON TODAY AND ADD COLUMN - variant data error??

Expressions that yield variant data-type cannot be used to define calculated columns.

PAST DUE =

VAR CONTRACTDATE = 'SALES CONTRACTS'[Contract Start Date]
VAR THISMONTH = EOMONTH ( TODAY () , 0 )
VAR PASTDUE = CONTRACTDATE < THISMONTH

RETURN
 
IF ( CONTRACTDATE = THISMONTH , "CURRENT MONTH",
IF ( CONTRACTDATE < THISMONTH , "PAST DUE",
CONTRACTDATE
)
)
1 ACCEPTED SOLUTION

Such a simple answer.  Yes, that worked but didn't truly solve my problem.   I'm trying to use a contact card marked as past due also as a filter/toggle for a table on the same page listing all the open contracts. 


Is monitoring past due (orders, contracts, shipments) best done as a measure or calcuated column in the represented tables or even as a column in a seperate date table?  
 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

columns must be the same data type throughout. You are trying to mix Text with, presumably, a date. Knowing that, what would your ideal scenario be?

TomMartens
Super User
Super User

Hey,

I'm not sure about the data type of the column '...'[Contract Start Date] but I assume it's of the datatype date or datetime.

 

As you return either the texts "CURRENT MONTH" or "PAST DUE" you should use the DAX formula FORMAT(..,) to convert the  column '...'[Contract Start Date] into a text like so:

FORMAT(CONTRACTDATE, "YYYY-MM-DD")

Hopefully this is what you are looking for.

 

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Such a simple answer.  Yes, that worked but didn't truly solve my problem.   I'm trying to use a contact card marked as past due also as a filter/toggle for a table on the same page listing all the open contracts. 


Is monitoring past due (orders, contracts, shipments) best done as a measure or calcuated column in the represented tables or even as a column in a seperate date table?  
 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.