Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am having problem calculating count of one column, based on MAX of another column.
I have to get a count of ticket IDs having score as "good", but only consider the rows with MAX created_at dates.
So, in this case, for the first ticket_id, the valuse will be "bad", and my count should have only 3 ticket_ids with "good" score. Can someone please guide me to the right DAX for the measure?
TIA
Solved! Go to Solution.
Hi @a_chhibber
Try this formula, Cnt_Max is the table name i have used.
Max_cnt = CALCULATE(COUNT(Cnt_Max[Score]), FILTER(Cnt_Max,Cnt_Max[Ticket_id]=EARLIER(Cnt_Max[Ticket_id])), FILTER(Cnt_Max,Cnt_Max[Score]="Good"), FILTER(Cnt_Max, Cnt_Max[Date]=CALCULATE(MAX(Cnt_Max[Date]), FILTER(Cnt_Max,Cnt_Max[Ticket_id]=EARLIER(Cnt_Max[Ticket_id])))) )
Thanks
Raj
Hi @a_chhibber
Try this formula, Cnt_Max is the table name i have used.
Max_cnt = CALCULATE(COUNT(Cnt_Max[Score]), FILTER(Cnt_Max,Cnt_Max[Ticket_id]=EARLIER(Cnt_Max[Ticket_id])), FILTER(Cnt_Max,Cnt_Max[Score]="Good"), FILTER(Cnt_Max, Cnt_Max[Date]=CALCULATE(MAX(Cnt_Max[Date]), FILTER(Cnt_Max,Cnt_Max[Ticket_id]=EARLIER(Cnt_Max[Ticket_id])))) )
Thanks
Raj
Thanks @Anonymous. But I am gettin the error "EARLIER / EARLIEST refers to an earlier row context which doesn't exist", with the following par underlined.
Max_cnt = CALCULATE(COUNT(Cnt_Max[Score]), FILTER(Cnt_Max,Cnt_Max[Ticket_id]=EARLIER(Cnt_Max[Ticket_id])), FILTER(Cnt_Max,Cnt_Max[Score]="Good"), FILTER(Cnt_Max, Cnt_Max[Date]=CALCULATE(MAX(Cnt_Max[Date]), FILTER(Cnt_Max,Cnt_Max[Ticket_id]=EARLIER(Cnt_Max[Ticket_id])))) )
@Anonymous, I was trying to use it as a measure. It worked now. Thanks again!!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
80 | |
60 | |
35 | |
35 |
User | Count |
---|---|
100 | |
62 | |
56 | |
47 | |
41 |