Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a column with percantage-values. I want to average all unique values from this column and display the static average result at every row! However; When I use different Dax codes that should do this - I get an "average" that alligns with the "gennemsnitCpr" value. The idea is simply to average a column filter free and display the same static value in all the new column's rows.
My query is:
kunde | total | cpr | cvr | gennemsnitICpr | Average |
NRGi | 200 | 254 | 202 | 89.50% | 89.50% |
NRGi | 200 | 254 | 020 | 89.50% | 89.50% |
NRGi | 200 | 254 | 344 | 89.50% | 89.50% |
HEF | 500 | 254 | 234 | 22.50% | 22.50% |
SydFyn | 600 | 254 | 234 | 90.55% | 90.55% |
Solved! Go to Solution.
No, it should be fine if you've already created a calculated column.
Here I have created the [gennes...] column in the data model the same as you have, then applied the formula that is giving the correct output:
Not sure why this isn't working for you.
Pete
Proud to be a Datanaut!
Hi @Anonymous ,
My first guess is that your [GennemsnitlCpr] field is not a numerical data type.
In Power Query, select this field and change the data type to decimal. Apply to the model, then see if your column works as expected.
Pete
Proud to be a Datanaut!
Hey @BA_Pete
Nope - Didnt help.
I found out how to get rid of "NaN". I simply changed my DAX code to:
Hi @Anonymous ,
Are you able to provide a sample of your data in table format please?
When you reply, you can use this button to add data in table format:
This makes it much quicker and easier for people to pick up a sample of your data for testing. This, in turn, means your question will be answered quicker.
Pete
Proud to be a Datanaut!
No problem, that's perfect.
Make sure that your source data looks like this in Power Query before applying to the model:
Then use the following DAX formula in a new column:
Average =
CALCULATE(
AVERAGE(aTable[gennemsnitICpr]),
ALL(aTable)
)
This gives me the following output (after changing the format to Percentage in the data model side, not Power Query side):
Pete
Proud to be a Datanaut!
Hey @BA_Pete
Hey, Pete.
How exactly do I express it as you have. Cuz I cant seem to make it appear like your formatting in your table?
Note; (gennemsnitICpr) is actually a division formula. So its value is based on the division of "cpr" / "total". I dont know if this makes a difference in the average calculation ?
@Anonymous
It looks like you're trying to change it in the data model rather than in Power Query.
Hit this button to open Power Query, where you can right-click on the column header and go to Change Type to change the DATA TYPE to decimal.
Then, still in Power Query, go to File>Close & Apply. This will push this change back into the data model.
Back in the model, you can then select that column again and change the FORMAT to Percentage.
Formats and Data Types are not the same thing.
Pete
Proud to be a Datanaut!
Hi @BA_Pete
Ah okay, I see!
Now there is another issue. Im essentially working on data thats coming from my company's live database. The column "gennemsnitICpr" is a column I have created in the data model overview as a division of two database-columns. If I go to Power Query I wont find "gennemsnitICpr".
Does this mean I can only do this to columns coming from a datasource?
No, it should be fine if you've already created a calculated column.
Here I have created the [gennes...] column in the data model the same as you have, then applied the formula that is giving the correct output:
Not sure why this isn't working for you.
Pete
Proud to be a Datanaut!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
53 | |
21 | |
12 | |
12 |