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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jimh153
Regular Visitor

Trying to us COUNT on a measure that Performs datediff

I use the following measure to calculate date difference what I am trying to do is then count how many are <=60 The measure works perfectly, I am looking to add cards to visual that will count how many are <=60 days remaining. 

 

DaysLeft = 
VAR PlannedComplete = [Planned Complete]
RETURN
 
SWITCH(
TRUE,
DATEVALUE(E1Data[Planned Complete]) < TODAY(), 0,
DATEVALUE(E1Data[Planned Complete]) >= TODAY(), DateDiff(Today(), DATEVALUE(E1Data[Planned Complete]), DAY))
1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

Thanks @lbendlin 

Hi, @jimh153 

Based on your description, I've created the following sample data:

vjianpengmsft_0-1715741489485.png

I create a calculated column using the DAX expression you provided:

vjianpengmsft_1-1715741530082.png

I use the following DAX to count DaysLeft less than 60 days:

CountDays60 = CALCULATE(COUNTROWS('Table'), FILTER('Table', [DaysLeft] <= 60))

Here are the results:

vjianpengmsft_2-1715741656975.png

I've provided the PBIX file used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

View solution in original post

3 REPLIES 3
v-jianpeng-msft
Community Support
Community Support

Thanks @lbendlin 

Hi, @jimh153 

Based on your description, I've created the following sample data:

vjianpengmsft_0-1715741489485.png

I create a calculated column using the DAX expression you provided:

vjianpengmsft_1-1715741530082.png

I use the following DAX to count DaysLeft less than 60 days:

CountDays60 = CALCULATE(COUNTROWS('Table'), FILTER('Table', [DaysLeft] <= 60))

Here are the results:

vjianpengmsft_2-1715741656975.png

I've provided the PBIX file used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

Thank you. I tried doing this and was not successful, but I tried it in power bi desktop version not the report server version i normally use and it worked. thank you again

lbendlin
Super User
Super User

You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.