Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi all,
I'm new to Power BI.
For my school, I'm trying to plot curves that show the percentage of students coming from the different regions of France, over the years.
From my main table, which contains one row per student, I could compute the number of students coming from these regions over the years, by using this DAX formula :
Number Per Region = SUMX( KEEPFILTERS(VALUES('Donnees-SCOL'[Annee])); CALCULATE(COUNT('Donnees-SCOL'[Departement_dernier_diplome])))
Where [Annee] is the year; [Departement_dernier_diplome] is the region of France.
The resulting plot looks like :
.
But I did not manage to calculate, for each year, the corresponding percentage of students coming from these regions
For a given year, I would expect something like : Percentage Per Region in Year = Number Per Region / TOTAL Number in Year.
Can anybody help me to find out the right DAX formula?
Thank you in advance,
Arnaud.
Solved! Go to Solution.
There are 2 options to achive that:-
1. Measure = COUNTA(TableName[Region])/CALCULATE(COUNTA(TableName[Region]),ALLSELECTED(TableName[Region]))
& Format it to %
2. Create Matrix Chart, Put Year in Rows, Region in Columns, Put Region again in Values (COUNT) and Select show value as Percent of Row Total
and finally convert Matrix Chart into Line Chart accordingly.
Hi again,
I worked on your solution 1 and actually modified the DAX formula you suggested, as follows:
Percentage Per Region = DISTINCTCOUNT('Donnees-SCOL'[ID])/
CALCULATE(DISTINCTCOUNT('Donnees-SCOL'[ID]);ALLSELECTED('Donnees-SCOL'[REGION]))
where ID is the student's ID; REGION is the region of France.
In fact, I had to make appear the number of "distinct" students somewhere in the formula.
I now obtain the plot I was looking for.
Thank you for your help: I did not know the function ALLSELECTED.
Best,
There are 2 options to achive that:-
1. Measure = COUNTA(TableName[Region])/CALCULATE(COUNTA(TableName[Region]),ALLSELECTED(TableName[Region]))
& Format it to %
2. Create Matrix Chart, Put Year in Rows, Region in Columns, Put Region again in Values (COUNT) and Select show value as Percent of Row Total
and finally convert Matrix Chart into Line Chart accordingly.
Many thanks. Worked a treat.
Thank you for your reply.
I've tried both solutions you suggested.
- First solution: Here is the plot I get:
Something's going wrong. Shouldn't the column [Annee] appear somewhere in the formula you suggested?
- Second solution:
Everything's going well until I'm trying to convert Matrix Chart into Line Chart. The plot looks like exactly the one I've just posted in my reply to Greg.
I'm a bit lost. If you have any further suggestion ...
Thank you in advance for your help,
Best.
Put columns in Line chart correctly, or share a screenshot of where did you put the dimentions/columns in the chart.
Also change it to % first as it does not look like % and hence straight line at 1.
Hi again,
I worked on your solution 1 and actually modified the DAX formula you suggested, as follows:
Percentage Per Region = DISTINCTCOUNT('Donnees-SCOL'[ID])/
CALCULATE(DISTINCTCOUNT('Donnees-SCOL'[ID]);ALLSELECTED('Donnees-SCOL'[REGION]))
where ID is the student's ID; REGION is the region of France.
In fact, I had to make appear the number of "distinct" students somewhere in the formula.
I now obtain the plot I was looking for.
Thank you for your help: I did not know the function ALLSELECTED.
Best,
Glad to hear that. You may help accept solution. Your contribution is highly appreciated.
Click on that visualization. Then, notice the little arrow for that measure/column in the Values area of your VISUALIZATIONS pane. Click that and then choose "Show value as | Percent of grand total".
Thank you Greg for your reply.
I've tried what you suggested.
Here is the resulting plot :
An issue occurs: the percentage is abnormally low; in fact, it is computed with respect to the grnad total. I would like it to be computed with respect to the total in a given year.
Any further idea? 🙂
Thank you in advance for your help,
Best,
It will be low as it is Percent of Grand Total, what you should do is create a Matrix Table first and then choose Percent of Row Total and then transform it into a Line Chart.
Hi @Greg_Deckler Percent of Grand Total is giving result based on all the years as a Total and for year wise percentage it should be Percent of Row Total, which is coming by going through Matrix Table first.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
84 | |
83 | |
72 | |
49 |
User | Count |
---|---|
143 | |
130 | |
108 | |
64 | |
55 |