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.
Hi,
I have a table similar to the following one:
Asset | State | Type | Samples |
AAAAA | 0 | X | 1000 |
AAAAA | 1 | X | 200 |
AAAAA | 2 | X | 300 |
AAAAA | 3 | X | 50 |
AAAAA | 0 | Y | 500 |
AAAAA | 1 | Y | 130 |
AAAAA | 2 | Y | 180 |
AAAAA | 3 | Y | 25 |
The only value I have is the number of samples for a given pair of State and Type.
I would like to diplay the data on a matrix visual, having States as rows and Type as columns.
I want to have 2 values for each combination, the first one being the number of samples, while the second one the percentage of samples of that type calculated over the total samples of the same type (beside of the state).
With the given sample table, for the state 0 row I should obtain:
Samples for type X = 1000
Percentage for type X = 1000/(1000+200+300+50) = 0,645 = 64.5%
Samples for type Y = 1000
Percentage for type Y = 500/(500+130+180+25) = 0,599 = 59.9%
I'm sure this should be pretty straightforward with DAX, but I'm facing more difficulties than I thought.
Can someone suggest me how to obtain this result?
Thank you.
Solved! Go to Solution.
Hi, @fpennisi17 , you might want to try this measure,
% Type =
DIVIDE (
MAX ( 'Table'[Samples] ),
CALCULATE ( SUM ( 'Table'[Samples] ), ALLEXCEPT ( 'Table', 'Table'[Type] ) )
)
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! |
@fpennisi17
Create two measure and add to a matrix;
Count = SUM(Table1[Samples])
----------------------------------------------------
Percent =
DIVIDE(
[Count],
CALCULATE(
[Count],
ALLSELECTED(Table1[State])
)
)
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi, @fpennisi17 , you might want to try this measure,
% Type =
DIVIDE (
MAX ( 'Table'[Samples] ),
CALCULATE ( SUM ( 'Table'[Samples] ), ALLEXCEPT ( 'Table', 'Table'[Type] ) )
)
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! |
Great!
Thank you!
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 |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |