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.
Good morning
Given the following example table:
Date Town Town Km_Asfaltados
1-2-2022 Madrid Getafe 10
3-2-2022 Seville Two Sisters 5
4-7-2022 Madrid Las Rozas 7
4-7-2022 Madrid Getafe 5
4-7-2022 Madrid Alcorcón 3
How can I calculate using DAX, the percentage of each town in asphalted km with respect to the total of km belonging to the same city of its corresponding day and show it in a new column?, I have tried to generate a summary table with "SUMARIZE" obtaining the subtotals by city, then creating a relationship between both tables by the city field to later use the function "DIVIDE" between the total of asphalted kg of each table to obtain the percentage, but I can not perform the formula well, plus I have the feeling that I am killing flies with cannon shots because I think it should be possible to do without generating a new summary table.
Please if you are so kind to throw me a cable to illuminate me, thank you very much!!
Greetings,
Jose.
Solved! Go to Solution.
Well indeed, it was complicating my life greatly. (It's what it takes to be a newbie at this xD)
As I have already solved it, I detail here the solution in case someone in the future could serve for a similar problem.
1.- I create a new measure that will house the totalization of the field Km_Asfaltados
ZMED_TotalKgAsfaltados = sum(Carreteras[Km_Asfaltados])
2.- I create a new calculated column that will obtain the total for each town.
ZCOL_Total_por_Pueblo =
CALCULATE(SUM(Carreteras[Km_Asfaltados]),ALLEXCEPT(Carreteras,Carreteras[Pueblo],Carreteras[Fecha]))
3.- I calculate the percentage that represents the asphalted km of that town with respect to the total of its province.
ZMED_%_S/Pueblo =
DIVIDE([ZMED_TotalKmAsfaltados], [ZCOL_Total_por_Pueblo])
Thanks a lot
Greetings!!.
Well indeed, it was complicating my life greatly. (It's what it takes to be a newbie at this xD)
As I have already solved it, I detail here the solution in case someone in the future could serve for a similar problem.
1.- I create a new measure that will house the totalization of the field Km_Asfaltados
ZMED_TotalKgAsfaltados = sum(Carreteras[Km_Asfaltados])
2.- I create a new calculated column that will obtain the total for each town.
ZCOL_Total_por_Pueblo =
CALCULATE(SUM(Carreteras[Km_Asfaltados]),ALLEXCEPT(Carreteras,Carreteras[Pueblo],Carreteras[Fecha]))
3.- I calculate the percentage that represents the asphalted km of that town with respect to the total of its province.
ZMED_%_S/Pueblo =
DIVIDE([ZMED_TotalKmAsfaltados], [ZCOL_Total_por_Pueblo])
Thanks a lot
Greetings!!.
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 |
---|---|
80 | |
76 | |
60 | |
36 | |
33 |
User | Count |
---|---|
91 | |
60 | |
59 | |
49 | |
45 |