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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
taher
Helper II
Helper II

count items filtered by DATEDIFF in direct query mode

Hi all,

 

I am using direct query and have this problem:

I want to count the useres which are not active since three months. Because of that I've created a measure which claculates the diffrence between today and the last active day for the users, so 1 for  not active , 0 for active .

Is inactive user since 90 days = IF( DATEDIFF(MAX('table'[TimestampUtc]);NOW();DAY)>90;1;0)

 

 It works well ! 

But when I need to create other measue which calculates the the count like this, I get this error:

count of inactive users = CALCULATE(DISTINCTCOUNT('table'[UserId]);[Is inaktiver Nutzer seit 90 Tagen]=1)

Unbenannt2.PNG

 

I have read that, this formula is not supported in direct query, so I went another way with a table like this but it doesn't count the number of 1 ( it seems it shows the average):

 

Unbenannt.PNG

What should I do !!

Thanks for Help 🙂

Taher

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@taher

 

Give this a shot

 

count of inactive users =
CALCULATE (
    DISTINCTCOUNT ( 'table'[UserId] ),
    FILTER (
        ALLSELECTED ( 'table'[UserId] ),
        [Is inaktiver Nutzer seit 90 Tagen] = 1
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@taher

 

Give this a shot

 

count of inactive users =
CALCULATE (
    DISTINCTCOUNT ( 'table'[UserId] ),
    FILTER (
        ALLSELECTED ( 'table'[UserId] ),
        [Is inaktiver Nutzer seit 90 Tagen] = 1
    )
)

Regards
Zubair

Please try my custom visuals

Hi @Zubair_Muhammad,

 

thanks, it works 🙂

 

 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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