This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I need some help with the DAX function for below logic
Problem statement : Need to bring a stacked bar chart visual where it shows total count of each category based on the latest Id number available for each dimension. Let me explain it with a sample data.
From below dataset, for the dimension - Customer there are totally 5 distinct elements. Now If I take the first element which is collaboration then as per the last ID which is Id 77 the category would be "Innovator". Moving on to the next element Confidence there is only one category transformer.Similary for the element Engagement as per latest Id 77 the category would be Innovator
Now considering only the first three elements of customer dimension . Total count of elements would be as below
Innovator - 2
Transformer -1
Expected output in the visual is as below
Sample Data :
| Element | Category | Id | Dimensions |
| Collaboration | Innovator | 77 | Customer |
| Collaboration | Transformer | 74 | Customer |
| Confidence | Transformer | 74 | Customer |
| Engagement | Innovator | 77 | Customer |
| Engagement | Transformer | 74 | Customer |
| Experience | Transformer | 74 | Customer |
| GoToMarket | Innovator | 77 | Customer |
| GoToMarket | Transformer | 74 | Customer |
Solved! Go to Solution.
Hi @Vijay08V ,
I suggest you to add an index column by Element group in Power Query Editor. This will make the calculation easier, we need a number column or date column to confirm the order of priority.
For reference: Create Row Number for Each Group in Power BI using Power Query
New Table:
Measure:
Count =
CALCULATE(DISTINCTCOUNT('Table'[Element]),'Table'[Index] = 1)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Vijay08V ,
I suggest you to add an index column by Element group in Power Query Editor. This will make the calculation easier, we need a number column or date column to confirm the order of priority.
For reference: Create Row Number for Each Group in Power BI using Power Query
New Table:
Measure:
Count =
CALCULATE(DISTINCTCOUNT('Table'[Element]),'Table'[Index] = 1)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@amitchandak Hi Amit - I tried using distinct count measure but its giving me total count of 8. However it should be 3 count for Inovator and 2 for Transformer element based on the latest Id number
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 36 | |
| 29 | |
| 29 | |
| 21 | |
| 18 |
| User | Count |
|---|---|
| 71 | |
| 45 | |
| 33 | |
| 24 | |
| 23 |