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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
kristina-brooly
Frequent Visitor

'Cannot convert value 'TRUE'of type Text to type Date'

Please help me with this measure. It gives the error:

 

'Cannot convert value 'TRUE'of type Text to type Date'

 

Current period users registrarions =
CALCULATE(COUNT('Users'[ID user]), FILTER('Users, DATEVALUE('Users'[Date of registration]>=MAX('Calendar'[Period begin]))), USERELATIONSHIP('Users'[Date of registration], 'Calendar'[Date]))
 
I changed data type to date in all participating columns, but still gives this error.
 
The company has their own periods, which start different date every month (Period begin) and they want to analyze users registrations for each period.
7 REPLIES 7
halfglassdarkly
Responsive Resident
Responsive Resident

Your use of FILTER('Users, DATEVALUE('Users'[Date of registration]>=MAX('Calendar'[Period begin]))) is taking the Boolean result from 'Users'[Date of registration]>=MAX('Calendar'[Period begin]) and trying to convert this to a date, hence the error. 

 

You shouldn't need to include DATEVALUE() as part of your filter at all.

johnt75
Super User
Super User

The problem is that you have the close bracket for DATEVALUE in the wrong place, it is enclosing the comparison with MAX Calendar period, which is a boolean.

If the columns are all dates there is no need to use DATEVALUE at all, you can use

Current period users registrarions =
CALCULATE (
    COUNT ( 'Users'[ID user] ),
    'Users'[Date of registration] >= MAX ( 'Calendar'[Period begin] ),
    USERELATIONSHIP ( 'Users'[Date of registration], 'Calendar'[Date] )
)

I tried to do how you wrote, but didn't get the desired result.

 

I need to calculate amount of users for the current (latest) period, registered after 09.02.2023

Am I doing wrong with dates comparison?

Period table is below:

 

periodperiod beginend date
2022_P908.09.202212.10.2022
2022_P1013.10.202209.11.2022
2022_P1110.11.202207.12.2022
2022_P1208.12.202211.01.2023
2023_P112.01.202308.02.2023
2023_P209.02.2023 

How is the period table related to the other tables, or is it just columns on the Calendar table ? Does each date in the Calendar table have a period begin and end date ?

these are just columns in Calendar.

Each date has period begin and the name of a period)))

Then I don't think you need to specify the filter. If your users table only has 1 row per user you can use

Current period users registrarions =
CALCULATE (
    COUNTROWS ( 'Users' ),
    USERELATIONSHIP ( 'Users'[Date of registration], 'Calendar'[Date] )
)

If there may be duplicates then you would need to change the COUNTROWS back to COUNT, but COUNTROWS is better.

In either case, you should be able to put that measure into a visual with the period start from the calendar table and it will show the number of users for that period.

If you just want the latest figure in a card visual or something, you could just put a filter on the card. Maybe add a column to the calendar table to return 1 if it is the latest period.

Greg_Deckler
Community Champion
Community Champion

@kristina-brooly Try:

Current period users registrarions =
CALCULATE(
  COUNT('Users'[ID user]), 
  FILTER('Users, DATEVALUE('Users'[Date of registration]) >= MAX('Calendar'[Period begin])), 
  USERELATIONSHIP('Users'[Date of registration], 'Calendar'[Date]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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