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
mohittimpus
Helper V
Helper V

Dax give message can't use True and False condition

CALCULATE(COUNT(customer[ID]),DATE(YEAR(TODAY())-1,DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))+TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW()))+dayInc))
 
 
var dayInc =
IF (
OR (
MOD ( YEAR ( SELECTEDVALUE ( customer[DATE] ) ), 400 ) = 0,
AND (
MOD ( YEAR ( SELECTEDVALUE ( customer[DATE] ) ), 4 ) = 0,
MOD ( YEAR ( SELECTEDVALUE ( customer[DATE] ) ), 100 ) <> 0
)
),
IF (
MONTH ( SELECTEDVALUE ( customer[DATE] ) ) = 1
|| MONTH ( SELECTEDVALUE ( customer[DATE] ) ) = 2,
1,
2
),
IF (
OR (
MOD ( ( YEAR ( SELECTEDVALUE ( customer[DATE] ) ) - 1 ), 400 ) = 0,
AND (
MOD ( ( YEAR ( SELECTEDVALUE ( customer[DATE] ) ) - 1 ), 4 ) = 0,
MOD ( ( YEAR ( SELECTEDVALUE ( customer[DATE] ) ) - 1 ), 100 ) <> 0
)
),
IF (
MONTH ( SELECTEDVALUE ( customer[DATE] ) ) = 1
|| MONTH ( SELECTEDVALUE ( customer[DATE] ) ) = 2,
2,
1
),
1
)
)
 
-------------------------------
 
I want to count of Value last year same week day till specifec time or currect time.

For Exmaple:  Today Date and Time will be:  09-05-2020 17:25  ----  I want count of last year till same time : 11 -05-2029 till 17:25.




1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

@Mayank08 

try like

 

Measure = 
var _Date =  
        DATE(
            YEAR(TODAY())-1,
            MONTH(TODAY()),
            DAY(TODAY())
        )
        +
        TIME(
            HOUR(NOW()),
            MINUTE(NOW()),
            SECOND(NOW())
        )
        +
        dayInc

RETURN

CALCULATE(
    COUNT(customer[ID]),
    dateTable[Date] >= _Date
)

 

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

8 REPLIES 8
Greg_Deckler
Super User
Super User

OK, it doesn't look like you even have three parameters for your first DATE function. The second parameter looks to be a return from a DATE function. This is all bad.

 

CALCULATE(
	COUNT(customer[ID]),
	DATE(
		YEAR(TODAY())-1,
		DATE(
			YEAR(TODAY())-1,
			MONTH(TODAY()),
			DAY(TODAY())
		)
		+
		TIME(
			HOUR(NOW()), 
			MINUTE(NOW()), 
			SECOND(NOW())
		)
		+
		dayInc
	)
)

 

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

When i useed your dax that give error message one "day" parameter is missing. 

 

I need use this date like this 

CALCULATE(

    COUNT(customer[ID]),

    

        DATE(

            YEAR(TODAY())-1,

            MONTH(TODAY()),

            DAY(TODAY())

        )

        +

        TIME(

            HOUR(NOW()),

            MINUTE(NOW()),

            SECOND(NOW())

        )

        +

        dayInc

    )

but this give this error message. 

"The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column."

az38
Community Champion
Community Champion

Hi @Mayank08 

you need compare your date with some filter. The second argument in CALCULATIE() is filter rule that can return boolean and not date, number or text


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Mayank08
Frequent Visitor


@az38 
Yes try fillter function but thi not work give over count. 

when i use this Dax this work good with Date but not with time. I just need help work with time

 

CALCULATE(
COUNT(customer[ID]),
    DATESBETWEEN(dateTable[Date],
        DATE(
            YEAR(TODAY())-1,
            MONTH(TODAY()),
            DAY(TODAY())
        )
        +
        TIME(
            HOUR(NOW()),
            MINUTE(NOW()),
            SECOND(NOW())
        )
        +
        dayInc,

    DATE(
            YEAR(TODAY())-1,
            MONTH(TODAY()),
            DAY(TODAY())
        )
        +
        TIME(
            HOUR(NOW()),
            MINUTE(NOW()),
            SECOND(NOW())
        )
        +
        dayInc
    
))
az38
Community Champion
Community Champion

@Mayank08 

try like

 

Measure = 
var _Date =  
        DATE(
            YEAR(TODAY())-1,
            MONTH(TODAY()),
            DAY(TODAY())
        )
        +
        TIME(
            HOUR(NOW()),
            MINUTE(NOW()),
            SECOND(NOW())
        )
        +
        dayInc

RETURN

CALCULATE(
    COUNT(customer[ID]),
    dateTable[Date] >= _Date
)

 

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

@az38 @Greg_Deckler 

 

I want this to be count. 

For Exmaple:  Today Date and Time will be:  09-05-2020 17:25  ----  I want count of last year till same time : 11 -05-2029 till 17:25.

 

That measure i am using it work with date level but not with time. so can you plz help on this

 

return CALCULATE(COUNT(customer[ID]),
DATESBETWEEN(dateTable[Date],
DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))+dayInc,
DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))+dayInc))

@az38  Thanks it work when i use like this way

 

var _Date =
DATE(
YEAR(TODAY())-1,
MONTH(TODAY()),
DAY(TODAY())
)
+
TIME(
HOUR(NOW()),
MINUTE(NOW()),
SECOND(NOW())
)
+
dayInc

var _Date1 =
DATE(
YEAR(TODAY())-1,
MONTH(TODAY()),
DAY(TODAY())
)
+
TIME(
HOUR(00),
MINUTE(00),
SECOND(00)
)
+
dayInc

RETURN

CALCULATE(
COUNT(customer[ID]),
customer[DateCreated] <= _Date,customer[DateCreated] >= _Date1
)
az38
Community Champion
Community Champion

@mohittimpus 

so, now its ok?

if so, please, mark appropriated solution to close the topic


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.