Calculate % of two columns Power BI - powerbi

I want to calculate % of two columns which are already in %.
I want to calculate formula like
Target achieved= ACTUAL/TARGET
But here is ACTUAL is already a measure/calculated metrics so I'm not able to divide these two columns.
Any help would be appreciated..

Make sure both target and actual are actually numbers and not strings. You can do it in transform data (aka Power Query) part, before data is loaded into the report.
After that you should be able to create the measure you want, e.g. something like that:
UPDATE : What happens if Actual is not a column, but a measure?
If Actual measure is based on the columns in the same table as target you shouldn't have a problem. You cannot combine measure and column in the same formula. Measure is an aggregated field and needs to be grouped by another field (if you are familiar with SQL,think of SUM and GROUP BY). Coming back to your problem, you need to create measure out of "Target" column as well (notice I have in the formula SUM('Table'[Plan]) which makes it a measure). Than you can use both of them in the formula, but of course you need to "group" them by something(e.g. date) otherwise it will just show you a total.

Related

Dynamic filtering based on selected value in slicer in Power BI

I am trying to create a calculated table where the data is being taken from another table and calculating the average based on the username, total average and variance between the 2 of these columns.
To create a table, I used the below DAX in Power BI which calculated the average based on the username.
scanner_speed_average_calculation =
SUMMARIZE(scanner_speed
,scanner_speed[user_name]
,"Average"
,AVERAGE(scanner_speed[order_processed]))
To calculate the group_average I used the below DAX:
group_average =
SUMMARIZE(
scanner_speed
, "Group Avg"
, average(scanner_speed[order_processed]))
And finally to calculate the variance, I used this query:
Variance = scanner_speed_average_calculation[Average] - scanner_speed_average_calculation[group_average]
Below is an outcome of these calculations.
I want to be able to make these calculations dynamic based on the selected value from the date. The table where I am taking these calculations do have the date value. I want to be able to use date range in slicer and I want these values to change based on the selected date range. I tried few things with Filter, Selectedvalue but I am not sure if I used them correctly.
Below is a main table where I took all these calculations from.
Below is a visual of where I want to group_average and variance. I want to be able to use date range and these columns should change accordingly.
Any idea or help will be appreciated. If possible then please put the entire formula. I am still a newbie in the world of DAX. Thanks in advance
power bi file
If you want a calculation to depend on a slicer, you need a Measure, not a calculated column or calculated table. Calculated columns and calculated tables are generated on refresh and physically stored in your model, so the slicers can filter them, but the slicers can't change the value of the calculations.
Measures are not persisted, but are calculated as needed based on changes to filters and slicers.
If you simply add add a measure
AverageOrdersProcessed := AVERAGE(scanner_speed[order_processed])
and put that on a visual that groups by user_name, you will get a the AVERAGE(scanner_speed[order_processed]) for each `user_name'.

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.

Power BI Table w/ Slicer Where Other Columns Adjust Parameters Based Off Selection

I have the following Power BI table example for an operating expense report that uses a slicer to filter the first column named "Actual". This is to see the operating expenses for one month compared to the budget figures for the year. It also compares the year-to-date and annual figures. How can I create dynamic columns that change based on the slicer selection? These additional columns are not shown in the pic below but included in the last pic. The Budget column below was just created as an example to show what it should look like.
I set up a star schema with several tables shown below. There's only one expense fact table used and the slicer only works for the first column as previously stated but I need all the other columns to use different parameters and adjust based off what's selected in the slicer. The last image is an overview of the info and the parameters for each column. I tried creating new columns with measures for the budget to see if I can get that going but can't figure out how to make it adjust with the slicer selection.
I'm not sure if I should be using separate queries for each column or can this be done using the one expense table. Hope this isn't too confusing. Please let me know if more info is needed.
If I understood what you wanted correctly I think I solved your problem.
I was able to create the following:
I did not use all values since I did not want to type everything, if you provide some test data it is easier to replicate you dashboard.
This matrix (so not table) allows you to filter for Date (if you so desire, you can always show all date's in the matrix) Book and AccountTree.
The way this is done is by putting the address column in the ROWS for the matrix, Putting the Date column in the COLUMNS of the matrix and putting your values (actual, budget, variance) in the values of the matrix.
For the date is used days, since it was easier to type. You can always use weeks, months, quarters or years.
For this to work you have to create the following relationships:
Hope this helps.
If not, please provide test data so it is easier to try and solve your problem.

Create Multiple Calculated columns using one DAX formula

Is it possible to create 2 different columns using one DAX Expression?
I have 2 column, for example Work Done this month and Invoiced Amount. I want to create 2 columns using these.
Work Done - Invoiced and return only positive values (Deferred)
Invoiced - Work Done and return only positive values (Extra)
Note: I know how to add these columns using 2 DAX formula's here, but I would like to know if its possible with one formula.
Samsple Screenshot below:
I believe it is possible but not within the existing table and it strongly depends on the context on which your are calculating. When your calculation is performed on a row level, ADDCOLUMNS could help you out. It allows you to create a new table and add multiple calculated columns.
https://learn.microsoft.com/en-us/dax/addcolumns-function-dax

Custom calculation for visualization

I am looking to create a custom calculation for a visualization in Power BI. In particular, I am looking to get a weighted average of my data.
My data set looks something like this:
Cluster Name | Node | Call Name | Errors | Calls
I would like to make a dashboard where I'm giving the percent error over time based on filters on the level of Cluster Name, Node, Call Name, or some combination of these. (The cluster name being the most broad and the call name being the least broad.)
I can easily set up a SQL query that gives me the percent error for each of these categories by doing SUM(Errors)/Sum(Calls) grouped by the category used and this is what I would like to replicate in my visualization.
The reason why I cannot simply calculate the percent error for the broader categories by taking an average of the simpler categories is that not every Call Name has an equal number of Calls. Therefore, I have to use a weighted average or simply recalculate SUM(Errors)/Sum(Calls) for each category selection.
I have tried to accomplish this using a custom column using DAX, but the numbers that the column calculates make no sense. My formula is PercentError = DIVIDE(MyTable[Errors], MyTable[Calls],0)*100, but the calculation seems to give really off numbers. For example, one row has 45 errors and 48 calls, but the percent error is listed as 2630.
Is there a way to do this through the visualization and/or the custom column calculations?
You can do this using a calculated measure rather than a calculated column. The formula would be exactly what you have described in your post
=SUM(Table[Errors])/SUM(Table[Calls])
Format as a % in the Modelling tab and voila.
Put your new measure in the values of a visual like a Matrix and put whatever columns you want to slice and dice this by in the Rows or Columns.