Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi there
I have a table where i store multiple appoiments for the same clients.
I need to calculate something called KPI4, which means the first appoiment where AppType is 2,3 or 5 and Attendance is 5 or 6.
Below in green is my table and i want the output as KPI_4 in red.
Doesnt necesarily have to be a calculated column, can be a measure as well.
I've been trying all day and i can't figure out how to use Min(Appoiment) with AppType and Attendance.
| ID | APPOINTMENT | APPTYPE | ATTENDANCE | KPI_4 |
| 859496 | 10/07/2017 | 2 | 3 | |
| 859496 | 14/07/2017 | 2 | 6 | 1 |
| 859496 | 17/07/2017 | 2 | 3 | |
| 888470 | 20/07/2017 | 3 | 5 | |
| 888470 | 10/07/2017 | 2 | 5 | 1 |
| 891491 | 05/07/2017 | 2 | 5 | 1 |
| 891667 | 04/08/2017 | 3 | 5 | |
| 891667 | 05/07/2017 | 2 | 6 | 1 |
| 891667 | 03/07/2017 | 3 | 2 | |
| 891667 | 06/07/2017 | 2 | 5 | |
| 901759 | 12/07/2017 | 3 | 5 | |
| 901759 | 18/07/2017 | 2 | 6 | |
| 901759 | 03/07/2017 | 5 | 5 | 1 |
| 907876 | 03/08/2017 | 2 | 5 | |
| 907876 | 06/07/2017 | 3 | 5 | 1 |
Solved! Go to Solution.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hello @mihaita_baro
You can create a column like this:
KPI_5 =
VAR a =
IF (
COUNTX ( FILTER ( ALL ( 'Table' ), [ID] = EARLIER ( 'Table'[ID] ) ), [ID] ) >= 2,
1
)
RETURN
IF (
a = 1
&& [APPTYPE]
IN { 2, 3, 5 }
&& [ATTENDANCE] IN { 5, 6, BLANK () },
1
)
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.
Best Regards,
Community Support Team _ Janey
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi,
I am getting the folowing error message.
Hi, @mihaita_baro
You wrote return part in the maxx function, which caused an error.
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.
Best Regards,
Community Support Team _ Janey
THanks, now it worked.
I have another KPI5 to calculate which means Clients must have at least 2 appoiments where AppType is 2,3 or 5 and Attendance is 5 or 6. or blank.
Not sure how i can count the appoiments based on multiple filters
Hello @mihaita_baro
You can create a column like this:
KPI_5 =
VAR a =
IF (
COUNTX ( FILTER ( ALL ( 'Table' ), [ID] = EARLIER ( 'Table'[ID] ) ), [ID] ) >= 2,
1
)
RETURN
IF (
a = 1
&& [APPTYPE]
IN { 2, 3, 5 }
&& [ATTENDANCE] IN { 5, 6, BLANK () },
1
)
Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.
Best Regards,
Community Support Team _ Janey
@mihaita_baro try this measure
First Appt =
VAR __date =
CALCULATE (
MAX ('Table'[APPOINTMENT] ),
TOPN (
1,
FILTER ( ALLEXCEPT ('Table','Table'[ID] ), 'Table'[ATTENDANCE] IN { 5, 6 } && 'Table'[APPTYPE] IN { 2, 3, 5 } ),
MAX ('Table'[APPOINTMENT] ),
ASC
)
)
RETURN
IF ( MAX ('Table'[APPOINTMENT] ) = __date, 1 ) + 0
✨ Follow us on LinkedIn
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) 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.
Hi
Thanks for your help but nothing comes up, it's all blank.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 50 | |
| 46 | |
| 35 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 88 | |
| 76 | |
| 41 | |
| 26 | |
| 26 |