I have a table like this:
I would like to calculate the result but some of ID column has different calculation formula.
For ID less or equal to 1733 using this formula: Value/3*100 for ID greater than 1733 using this formula Value*100
I tried this way:
Result =
IF('Data'[ID]<=1733,[Value]/23*100)
IF('Data'[ID]>1733,[Value]*100)
But it return an empty value. Anyone could help me please.
Thank you so much
This can be achieved using IF statement by following way by creating a calculated column called "Result"
Result = IF(Data[ID]<="1733",(Data[VALUE]/23)*100,Data[VALUE]*100)
Hope this helps !!
If the [ID] is a text then you can convert it to a number with the VALUE(). When you are trying to convert number to text with quotes then you will get a wrong result for some of values. For text comparison it works like this: "11111"<"2", for number 11111 > 2. For a calculated column it not necessary to write a full column name like 'Data'[ID], you can simply write [ID], because of a row context. DAX will understand that the value and row you are working with is in a current table.
Result =
SWITCH(
TRUE()
,VALUE([ID])<=1733,[VALUE]/23*100
,[VALUE]*100
)
Related
I'm struggling within DAX to find a formula to return the first result. My table is as folllows:
The unique column is Dim_B_ID. So what I really would like to have is to return the first result of Amount ONLY for Dim_B_ID where the column IN is not blank. Im struggling cause I get answers like 3500 (total of the rows) and I can't seem to integrate IF(NOT(ISBLANK( funtion into this. So if someone has a solution for me, I would really appreciate it as I'm not so much of an expert in DAX.
You could try using the following measure:
FirstNonBlank =
FIRSTNONBLANKVALUE(
'Table'[Dim_Date_ID],
SUM( 'Table'[IN] )
)
When put together with Dim_B_ID in a table for example you could visualize FirstNonBlank for every "categorie" like so:
Used slightly modified sample data here:
While I am trying to create a new measure, with condition, I am facing the below error.
I am trying to create a dynamic line based on dates on my line graph. For my case, if Sheet[Date] matches to Test[Date] it should return me a value of 100.
But the error says that a single value for column 'Date' in table Sheet1 cannot be determined.
I also tried to convert the date to week with Weeknum function. But the error still persists.
Does it mean that I can not compare single values in IF condition
If there is a way to compare the dates, kindly guide me.
Sheet[Date] and Test[Date] are columns, not single values.
You need to specify which single values from those columns to compare. For example, you could compare the maximal values of those columns (within the local filter context):
MAX ( Sheet[Date] ) = MAX ( Sheet[Date] )
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.