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

Count of Measure which calculates max dates

So I had to calculate the max date for a set of object IDs according to a max date. A sample of the original data:

NaCingolani_0-1623876527215.png

 

So I used the following measure which gives me the desired result:

 

MaxDate = 

var _id = SELECTEDVALUE(TABLE[Object ID])

return

CALCULATE( MAX(TABLE[Approval Date]), TABLE[Object ID] = _id)

 

The thing is that now after this expression, I need to be able to count the object IDs for each Max Date achived in the MaxDate measure. How should I proceed? I ve tried using different COUNT and CALCULATE expressions but to no success. 

 

Thanks!

1 ACCEPTED SOLUTION

Hi  @Anonymous ,

 

Create  a slicer table as below:

Slicer table = VALUES('Table'[ObjectID])

If you use Id from oringinal table as a slicer,it will affect the measure result.

Then create a measure as below:

count = CALCULATE(DISTINCTCOUNT('Table'[ObjectID]),FILTER(ALL('Table'),'Table'[Approval date]=[Maxdate]))

You could also use the measure suggested by @parry2k.But do remember to create a slicer table first.

For the sample .pbix file,pls check attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@Anonymous I surely missed that part of the post, sorry about that. Continuing on my measure,  create MAX Date measure as mentioned before and then add this measure to count 

 

Count matches with max date = 
SUMX ( 
    Object,
    IF ( Object[Approval Date] = [Max date], 1 )
)

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous I don't know what you ask is? Your original question was to get the max date for each object id and that's what the measure is doing? if you need something different, you should close this post and add create a new one.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi Parry,

 

First of all, thanks for your continous support and feedback.

Unfortunately, what you are saying is wrong. That was not my original ask. I think you may have only read a few words of the first sentence and not the whole post. If you read the original post, and I quote below:

The thing is that now after this expression, I need to be able to count the object IDs for each Max Date achived in the MaxDate measure. How should I proceed? 

Im not sure if you missed it. Thanks again!

Hi  @Anonymous ,

 

Create  a slicer table as below:

Slicer table = VALUES('Table'[ObjectID])

If you use Id from oringinal table as a slicer,it will affect the measure result.

Then create a measure as below:

count = CALCULATE(DISTINCTCOUNT('Table'[ObjectID]),FILTER(ALL('Table'),'Table'[Approval date]=[Maxdate]))

You could also use the measure suggested by @parry2k.But do remember to create a slicer table first.

For the sample .pbix file,pls check attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

parry2k
Super User
Super User

@Anonymous try the following measure:

 

Max Date = CALCULATE ( MAX ( Table[Date] ), ALLEXCEPT ( Table, Tale[ObjectId] ) )

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Not getting the result I want.

 

The Measure "Max Date" that I gave above gives me for each Object ID, the max date of all the steps of each Object ID --> Now, I need to be able to count those Object ID according to that Max Date. Maybe this helps to understand the result Im looking for.

Regards

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.