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
vivran22
Community Champion
Community Champion

Measure Help: Conditional Count

Dear Community Members,

 

Need your help in the following:

 

I have a dataset:

 

Task IDTimestampStatus
ABC2/2/2020 4:45To-Do
ABC2/12/2020 23:52Planned
ABC3/5/2020 16:18Planned
ABC3/10/2020 14:50To-Do
DEF1/9/2020 17:42Completed - Late
DEF3/5/2020 12:08Completed
DEF3/10/2020 22:26Overdue
DEF3/14/2020 2:01To-Do
CED1/4/2020 9:58To-Do
CED2/10/2020 23:49To-Do
CED2/12/2020 0:11Planned
CED3/10/2020 1:06Completed
AJC1/9/2020 11:56Planned
AJC1/9/2020 17:38Overdue
AJC2/3/2020 19:08Completed - Late
AJC2/5/2020 11:38Overdue
ADR1/3/2020 13:32To-Do
ADR2/13/2020 12:10To-Do
ADR3/6/2020 1:50To-Do
ADR3/9/2020 1:20Planned
GJK1/11/2020 4:10Completed
GJK3/1/2020 1:18Completed - Late
GJK3/5/2020 0:20Planned
GJK3/6/2020 6:07Completed
VKL2/15/2020 13:27Completed - Late
VKL3/5/2020 15:03Overdue
VKL3/11/2020 0:25Planned
VKL3/13/2020 4:06Overdue

 

What I need is to create a MEASURE which gives the count of status by latest time stamp:

 

Dataset.PNG

 

Output required:

 

StatusCount
To-Do2
Completed2
Overdue2
Planned1

 

There is a limitation of source data as Push data, hence cannot create any table or additional column.

 

@amitchandak @Greg_Deckler @Ashish_Mathur @MFelix 

 

Cheers!
Vivek

1 ACCEPTED SOLUTION

Hi,

You may download the PBI file from this Blog article - Count tasks by status.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

14 REPLIES 14
Anonymous
Not applicable

Hey @Anonymous 

 

Thank you for your response. 

 

The solution you have provided is quite intuitive but the constraint is that there cannot be any support table, nor I can use Power Query. I was running out of options hence looking for expert's advise.

 

Solution provided by @Ashish_Mathur worked on the sample dataset, but didn't work on complete dataset.

 

Please advise if there is any other alternative.

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

Anonymous
Not applicable

If you want the output in a visual (table, matrix) in PBI, it's dead easy. One sec.

Best
D
Ashish_Mathur
Super User
Super User

Hi,

You may refer to my solution here.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur 

 

Thank you for your resposne.

 

I tried to incorporate it in my file, but it didn't work. Please advise.

 

Sample file here

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

Hi,

I opened a PowerBI Desktop file and and went to File > Import > Power Query, Power Pivot and Power View.  Clicked on OK and then built a simple Table visual.  I got the same results that you expected to see (see image below).  Please cross all your formulas carefully once again.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 

 

Your solution worked perfectly when applied on the sample dataset on Power BI desktop. But when I tried replicating it on the orignal dataset, it didnot work. Hence, I shared the pbix file with orignal dataset.

 

You can get it from here

 

I appreciate your time and support.

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

Hi,

You may download the PBI file from this Blog article - Count tasks by status.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur ,

 

Need your help in this:

 

Using the solution you had provided, I could create the following visual:

visual.png

 

 

But when I am trying to replicate it on my orignal dataset, I am getting the error:

error.PNG

 

Not sure what is causing this. Please advise.

 

Sample pbix file

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

Hi,

It looks like for one Task ID there are multiple task owners.  That is causing a problem with the result of this measure - 

Status of last time stamp and of course the others measures which use this one as an input.

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur ,

 

It had worked well on the sample dataset but when I updated the records, I am not getting the required calculation.

 

I checked for duplicate entries as advised by you but couldn’t find any. This is a tricky situation for me and I was hoping if you could provide more support on this:

 

For simplicity, I have created two tables. What I am looking for is to create a visuals like the first segment:

Snapshot.png

 

 

Sample pbix file

 

Regards,

Vivek

This is quite a tricky problem for DAX . If you don't need all the data loaded, one solution is to use power query to solve the problem. You can use a groupby step in power query and extract the maximum date and the value from the status column. If you download this summarised table you will get the information you need. Of course if you need the other data as well then this may be a problem



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.