Column of Total Average Power BI - powerbi

got stuck with this one for a while. Need to repeat 165608547,90 in a Separate Column. Simple AVERAGEX(Sales[Turnover]) does not work. Thank you for any help

This would be best achieved through using a DAX measure.
Avg Cost = CALCULATE(AVERAGE('YourTable'[Amount]), ALL('YourTable'))
As per the comments added, if you want existing slicers to be respected, use ALLSELECTED in place of ALL. In some cases ALLEXCEPT could also be a solution.
Note, this must be a measure and not a column.
This measure will provide the average for everything in the table when it is added as a field in the matrix/table. The ALL keyword removes any filters applied to the data during the calculation.
See DAX ALL

Related

How to add same measure used in different vizualiztions. power Bi?

I have a measure [expense]. I have two filters filter1(current year expense) and filter2(prev year expense)
I have created two table in a Power Bi report, and used the same measure expense in them both of them such that,
The first table ignores filter 2(prev year expense) and only filter1(current year expense) is applied
The second table ignores filter1 and only filter 2 accepts.
Basically I want to have Current year and prev year expense in two separate tables. This I am able to achieve quite easily, using edit interactions.
But the problem is I also need a third table which should give the result as the total of the two tables. Since I am using the same measure in both the tables, how can I achieve this.
Note:: My total table total summation should change based on filters selected .
Basically table3=table1+table2.
Try something like this. Filter the third table with filter1(current year expense). I do not see better solution within your report logic.
CALCULATE(
[expense]
,tbl[Year] In {SELECTEDVALUE(tbl[Year]),SELECTEDVALUE(tbl[Year])-1}
)

power bi measure with 2 conditions 2 calculate

I am trying to create a measure which will calculate the Total Project Revenue
while I have 2 different projects. For each project there is a different calculation:
for Hourly project the calculation should be: Income * BillHours
for Retainer project the calculation should be: Income*TotalWorkinghours
I wrote the below DAX:
enter code here : Total project revenue = IF(max(DimProjects[ProjectType])="Hours",
max(FactWorkingHours[Income])[BillHours],max(FactWorkingHours[Income])*
[Total Working Hours])
the rows are calculated correctly but the total in the table is wrong
what should I fix in DAX so the total of all raw will correct as well.
The total Revenue should be 126,403.33
Thank you in advance
you can find here the table with the results
It's hard to say exactly what your measure is doing because, as written here, that is not a valid measure. I pasted it into the DAX Formatter, which I would recommend for formatting and pasting here into code blocks, and the measure was invalid. It would also be helpful to post the other measures this measure references, eg. [Bill Hours] and [Income Hours].
That being said, I think I can kind of tell what's going on. Your total is probably wrong because the filter context at the total level is being based of the condition where:
MAX ( DimProjects[ProjectType] ) = "Retainer" (or some other value not in your shared snippet)
That is because when you consider the MAX of a string, the higher alphabetical order is considered. Therefore, "Retainer" > "Hours". So at the total level, your table is outputting—more than likely, I can't be certain without more information—the false condition of your measure:
MAX ( FactWorkingHours[Income] ) * [Total Working Hours])
There is a better way to handle your intended outcome. IF statements, in the way you are attempting to use it, are rarely used in a calculated measure. You may be better off trying a calculated column without using the MAX functions. Again, I can't give an exact code recommendation without more context. Hope that sends you in the right direction!

Power BI DAX - Measure to change name of row value

I need some help creating a measure to change the name of "FROM_USER" in the slicer here.
I think I need to use the function SELECTEDVALUE, but I have not managed to get it working.
So, the column has only two values, CRAWLER and FROM_USER.
Any suggestions would be helpful!
See picture
Measures can't be used as slicer values. If you want the column values to be changed and yet to be used in a slicer, you need to create a calculate column to change that.
Column = IF('Table'[Column1]="FROM_USER","desiredValue","CRAWLER")
If you are really keen on using a measure to slice, you need to build a disconnected table and follow the method described here. But the performance will take a hit depending on how complex your data model and calculations are.

Show measure only when another filter is active

I'm very new to Power BI, so please be kind as I'm trying my best to learn.
I'm creating a measure that shows the average of all historic data from a given instrument (I can select the instrument from a chart in the dashboard).
The thing is: the average has meaning only when I select one instrument. When two or more instruments are selected, I don't want to show the average.
The average is calculated by data on a table that has the columns: Instrument_ID, date, time, elevation (that's the column where I calculate the average).
Can someone give me directions of what to do please? Thanks for your time!
This is possible, with two methods,
Set the slicer to only allow one value selection
or
Check if the slicer only has one value selected using HASONEVALUE
Your DAX will have to be wrapped with an IF statement, and assuming that the slicer is using the 'Instrument_ID'
Your measure = IF(HASONEVALUE(tablename'Instrument_ID'), CALCULATE(AVERAGE(table[elevation])), BLANK())
You are not doing a compare in your IF statement, as HASONEVALUE will return a True/False. If the selected item only has one value, then it will return your measure, else in this case blank.

Filtered LOD calculations in DAX expression Power BI

I have created LOD expressions in Tableau before which dynamically calculate when filters are applied. I am trying to achieve similar functionality in Power BI. I am very new to Power BI so I probably didn't ask google the right question. I simply want a column that shows the average sales over my "Filtered" data set. The closest I cam was using the Calculate(average(table[column]),All(table)) but that does not dynamically change when I apply the date slider. If I filter for 1/1 - 1/5 I want that average. Change the date range, the average should change.
Thank you.
You are probably looking for the ALLEXCEPT() function. In this case you would do something like
CALCULATE(AVERAGE(table[column]), ALLEXCEPT(table, table[date]))
that is basically saying that you want to remove all filters on the table except the filters on the date column.
CALCULATE(
AVERAGE(Table[Column]),
ALLSELECTED()
)