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
Anonymous
Not applicable

date diff-row count if condition apply

Dear Friends

 

i have two dates column date1 and date2,

Capture.JPG

 

and calculatting the difference by measure by comparing constant value Z=3:

 

Measure =
var z=3
VAR diff=SUMX(Sheet1,DATEDIFF(Sheet1[date1].[Date],Sheet1[date2].[Date],DAY))
var result =IF(diff>z,1,0)
return result
 
its appearing in the table list but can not get total at last or in Card
 
result.JPG

 
How can i solve this through measures (not by creating calculated column)
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Rename your current measure to be Measure Individual and then create a new measure

Measure = IF( ISINSCOPE( 'Table'[date1]), [Measure Individual],
SUMX( ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[date1], 'Table'[date2]),
   "@val", [Measure Individual] ),
[@val] )
)

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Create a measure.

Measure =
VAR _Count =
    COUNTROWS (
        FILTER ( 'Table', DATEDIFF ( 'Table'[date1], 'Table'[date2], DAY ) > 3 )
    )
RETURN
    IF ( ISBLANK ( _Count ), 0, _Count )

Get the correct result.

vkalyjmsft_0-1648889150607.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

johnt75
Super User
Super User

Rename your current measure to be Measure Individual and then create a new measure

Measure = IF( ISINSCOPE( 'Table'[date1]), [Measure Individual],
SUMX( ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[date1], 'Table'[date2]),
   "@val", [Measure Individual] ),
[@val] )
)

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.