cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
oroberto Frequent Visitor
Frequent Visitor

Count on condition from multiple sorting condition

Hi,

 

I'm trying to create a new custom column for my table which it's gonna count the sort order from other collumns on some condition:

1. it's should be on the same date

2. it should be sorted on it's value on descending order

 

this is the image for what I want to do:

date_column      |       value_column     |          my_custom_column     |

2019/06/14        |                 8               |                         3                    |

2019/06/14        |                 9               |                         2                    |

2019/06/14        |                10              |                         1                    |

2019/06/15        |                 7               |                         2                    |

2019/06/15        |                 8               |                         1                    |

 

I've tried this DAX code :

CALCULATE(COUNT('my_table'[value_column]),FILTER('my_table',AND([date_column]=MAX([date_column]),[value_column]<MAX([value_column]))))

but it's not returning the result that I want.

 

I wondering if there's someone who has a better idea for this.

 

regards,

1 ACCEPTED SOLUTION

Accepted Solutions
oroberto Frequent Visitor
Frequent Visitor

Re: Count on condition from multiple sorting condition

hi @Ashish_Mathur ,

 

thank you very much for your help.

it's close from what I'm looking for, but the problem is, with your code rows with date earlier than 2019/06/14 would also be counted.

I need rows to be counted only on the same day

 

キャプチャ.png

View solution in original post

5 REPLIES 5
Super User IV
Super User IV

Re: Count on condition from multiple sorting condition

Hi,

This calculated column formula works

=CALCULATE(COUNTROWS(Data),FILTER(Data,Data[date_column]=EARLIER(Data[date_column])&&Data[value_column]>=EARLIER(Data[value_column])))

Hope this helps.

Untitled.png


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

Re: Count on condition from multiple sorting condition

hi @Ashish_Mathur ,

 

thank you very much for your help.

it's close from what I'm looking for, but the problem is, with your code rows with date earlier than 2019/06/14 would also be counted.

I need rows to be counted only on the same day

 

キャプチャ.png

View solution in original post

Super User IV
Super User IV

Re: Count on condition from multiple sorting condition

Hi,

Your formula is not the same as mine.  You are missing the EARLIER() before the &&


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

Re: Count on condition from multiple sorting condition

Hi @Ashish_Mathur 

 

sorry for that.

it works perfectly now!

thank you very much, really appriciate it!

 

regards,

Super User IV
Super User IV

Re: Count on condition from multiple sorting condition

You are welcome.  If my reply helped, please mark it as Answer.


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

Helpful resources

Announcements
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors