My goal is to aggregate values in a single column based on groups of other columns.
For example my table looks like:
https://imgur.com/YbTFDh2
and the desired output would be something like this:
https://imgur.com/5It0KgW
I can do this on the same table or create a new table.
I have attemped this:
SUMMARIZECOLUMNS (
'Sheet1 (2)'[Item],
'Sheet1 (2)'[Name],
"Total", SUM([Money])
)
but the error returned is: *The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.*z
EDIT
Ultimately my end goal is to create a calculated column to round the dollar up based on a series of ranges using SWITCH function.
=SWITCH(TRUE(),[Money] <= 10, 0, [Money] <= 20, 10)
...something like that.
The easiest thing to do would be create a simple measure:
Total=SUM([Money])
Then, you can view this in Power BI by putting the Name on an axis:
Like this...
Table Example
Or this...
Bar Chart Example
In Excel, you could use Pivot Tables to show the same thing.
You can achieve a sum of each group rounded down to the nearest 10 using the following:
Answer =
FLOOR ( SUM ( 'Sheet1 (2)'[Money] ), 10 )
FLOOR() takes the Sum of your "Money" column as the first argument, and your required multiple (in this case 10) as the second. CEILING() and MROUND() can be used alternatively if you want to round up, or to the nearest value.
EDIT:
Based on your recent comments, perhaps something like this would be more appropriate:
Answer =
IF(SUM('Sheet1 (2)'[Money]) < 10, 0,
IF(SUM('Sheet1 (2)'[Money]) < 20, 10,
IF(SUM('Sheet1 (2)'[Money]) < 25, 20, BLANK())))
SWITCH can only be used with constants, so you'll need to chain together some IF statements to get what you're looking for.
Related
I have a table of number of visual:
visual_1000x123
0
1
I would like to use a dropdown list to let people select 0 or 1.
If 1 is selected, the calculate result will be xxx(let's say 55k).
If 0 is selected, the calculate will be 0.
Maybe I should mention that there is a time filter, which works well.
The result varies according to the selected period.
This measure keeps giving me 0:
measure = IF(MAX('Simulateur'[visual_1000x123])=0, 0,
CALCULATE(SUM('Prévision Leaderboard'[Budget_impressions/1000x123_et_1000x167])) +
CALCULATE(SUM('Prévision Middleboard'[Budget_impressions/1000x123_et_1000x167])))
This measure keeps return 55k:
measure = IF(MAX('Simulateur'[visual_1000x123])=1, 0,
CALCULATE(SUM('Prévision Leaderboard'[Budget_impressions/1000x123_et_1000x167]))+CALCULATE(SUM('Prévision Middleboard'[Budget_impressions/1000x123_et_1000x167])))
I also tried to multiply the number of visual, but it didn't return anything:
measure =
(CALCULATE(SUM('Prévision Leaderboard'[Budget_impressions/1000x123_et_1000x167])) +
CALCULATE(SUM('Prévision Middleboard'[Budget_impressions/1000x123_et_1000x167])))*MAX('Simulateur'[1000x123])
If I am understanding your question correctly, you just want to multiply a number in a column by a factor (which is in a slicer, or visual).
If that is the case you can do it simply as follows:
column1 * factor result = AVERAGE('Table'[Column1]) * AVERAGE('Table (2)'[factor])
Posting this answer myself.
It's due to my data structure. All the data was in one table and I should have them seperated into different tables.
I think I have just been staring at this for too long and have worked myself into a corner.
So let's say I have the following data:
I have locations that get monthly utility usage numbers. I want to create a clustered bar chart that shows how many months have data.
The "Merge_Use" column can have numbers, blanks, and N/A. Any number > 0 OR N/A is considered complete. 0 or blank is incomplete.
I want a clustered bar chart that shows % complete, and is split by quarter and metric type, that shows the global total % complete, but can be filtered to show the % complete by region or individual location (relationships for TRT_ID to region is housed in a separate table). For some reason I can't wrap my mind around the measure that would do that.
This was my first try. I used a calculated column, but it wasn't until after I got to the visual stage that I realized that my calculated column is static and won't be affected by filtering. (It sounds silly now but I made a column that assigned each completed field a % out of the total fields, i.e. 1/total # rows, thinking I could just sum these together in the visual).
How would you do this?
I may have solved my own problem.
I added a conditional column with Yes/No for "completed" based off my criteria. (i.e. if "" then "No", else "Yes")
Then added the following measure:
% YES =
DIVIDE (
CALCULATE ( COUNT ( Leadership_Usage_Tracking_v2[Completed] ), Leadership_Usage_Tracking_v2[Completed] = "YES" ),
CALCULATE ( COUNT ( Leadership_Usage_Tracking_v2[Completed] ), ALLSELECTED ( Leadership_Usage_Tracking_v2[Completed] ) )
)
Seems to be working so far!
Objective:
I would like to make a measure and a calculated column (for the sake of knowing how to write both) using an IF statement but can't get it to work
Query:
Column =
IF(
Refund[orderTotalPrice]=Refund[amount] && Refund[status] = 'refund' ,
Refund[amount] - Refund[total_tax]- Refund[shipping_price],
Refund[amount]
)
the expression refers to multiple columns multiple columns cannot be converted to a scalar value
When creating an if statement in a calculated column you can only have one comparison statement. If you want 2, like in your example, you need to use the AND function. Also make sure you use " instead of ' for string comparison.
I tested this calculated column and this worked for me:
Column = if(
AND(Refund[orderPriceTotal]=Refund[amount],Refund[status]="Refund"),
Refund[amount] - Refund[total_tax] - Refund[shipping price],
Refund[amount]
)
In your case, I do not think there is an easy solution to solve this in a measure. Why would you want to build it as a measure?
I have the following table and am trying to get the sum of a particular column. First Table
I would like to take distinct values for the 'TrackerID' and when durationConnected is greater than 0, then take the value greater than 0. In the end I would like to get the sum which in this case is 7. (See second table):
Second Table
I tried creating another table by doing the following: AnotherTableTest = SUMMARIZE(journal;journal[PhoneNumber];journal[StartTime];journal[TrackerID];"UniqueCalls";DISTINCTCOUNT(journal[TrackerID]);"TimeConnected";Max(journal[DurationConnected])). This didn't give me the expected result.
I also tried using a measure:
MaxAmount = MAX(journal[DurationConnected])
ActualAmount = SUMX(DISTINCT(journal[TrackerID]);[MaxAmount])
Can anyone help me please?
Try creating a new table like this:
newTable = SUMMARIZECOLUMNS('journal'[TrackerID],
"StartTime", MAX('journal'[StartTime]),
"totalDuration",SUM('journal'[DurationConnected]))
EDIT
When [DurationConnected] is the only value that changes for each [TrackerID], this answer is a bit cleaner. I also added 'journal'[Outbound] on OP's request (see comments).
newTable = SUMMARIZECOLUMNS('journal'[TrackerID],
('journal'[StartTime]),('journal'[Outbound]),
"totalDuration",SUM('journal'[DurationConnected]))
I have 2 column; ID CODE, value
Remove duplicates function will remove the examples with the higher value and leave the lower one. Is there any way to remove the lower ones? The result I expected was like this.
I've tried Buffer Table function before but it doesn't work. Seems like Buffer Table just works with date-related data (newest-latest).
You could use SUMMARIZE which can be used similar to a SQL query that takes a MIN value for a column, grouped by some other column.
In the example below, MIN([value]) is taken, given a new column name "MinValue", which is grouped by IDCode. This should return the min value for each IDCode.
NewCalculatedTable =
SUMMARIZE(yourTablename, yourTablename[IDCode], "MinValue", MIN(yourTablename[value]) )
Alternatively, if you want the higher values just replace the MIN function with MAX.