I have a column named Cur_bal in power bi I just want to know what day function could help me change all negative a to 0 and keep all other values the same.
You can use either a calculated column or a measure. The formula for a calculated column would be:
Cur_Bal - Positive_Only =
IF ( 'Table'[Cur_Bal] < 0, 0, 'Table'[Cur_Bal] )
Once you have that, you can use it in an implicit or explicit measure to sum up the total.
For a measure, it would look like this:
Cur_Bal - Positive_Only (measure) =
CALCULATE ( SUM ( 'Table'[Cur_Bal] ), 'Table'[Cur_Bal] > 0 )
The measure uses a CALCULATE function with a simple filter on Cur_bal column.
Link to image of output sample table...
Related
I have data like:
Folder Replied Complied
1 testing 1 1
2 /complete/ 0 1
3 none 1 1
4 Incomplete 0 1
5 complete// 0 0
6 Incomplete 1 0
7 ABCcomplete 1 1
I like a measure to calculate the average of Complied (sum divided by count), only where Folder contains the string complete AND Replied is 0 (both conditions simultaneously).
Therefore rows 2, 4, 5 should be used in the count, resulting in 0.66... (1 + 1 + 0)/3
i've tried several things but the formula either results in an error, or returns the wrong result
i.e.
Measure = CALCULATE (
Average( [Complied]),
CONTAINSSTRING([Folder],"complete") && [replied] = 0
)
DAX is very confusing to me. Thanks in advance
edit:
I've seen examples like
`
= CALCULATE(AVERAGE([col]), CONTAINSSTRING([Folder],"complete") , [replied] = 0)
note the , instead of && but that doesn't work for some reason either. Neither does AND(condition1, condition2).
This dax measure should be the one you are looking for:
Measure = CALCULATE(AVERAGE(Sheet1[Complied]),
CONTAINSSTRING(Sheet1[Folder],"complete") && Sheet1[Replied]=0)
So how is it working?
ContainString to check about "complete", work like VBA instr function
&& in order to meet both condition
Calculate(method, expression) to filter all the value
Scorecard
You may first test with the following measure to check if statement is working in your case first:
IF(CONTAINSSTRING(Sheet1[Folder],"complete") && Sheet1[Replied]=0,"True","False")
Only three row is True here:
I'm new to Power BI so I may have titled this wrong but I'm trying to use a SUMPRODUCT in my table but the total is incorrect.
My goal is to take the SUMPRODUCT of (Linear_Feet_Out,Hrs) / SUM(Linear_Feet_Out)
So I broke it down to try and solve the problem but am having no luck. Slitting_Time_New is just my est field to make sure each row is calculating correctly. So 2.000 * 226,795 = 453,589
However the results I am expecting are 2.54 in the "Slitting_Time_Avg" field total.
Here is what I have so far:
Slitting_Time_Avg =
VAR Numerator = [Slitting_Time_New]
VAR Denominator =
SUM (Mfng_Analysis[Linear_Footage_Out] )
RETURN
CALCULATE ( DIVIDE ( Numerator, Denominator ) )
But I want it to take the sum of Slitting_Time_New (a calc measure), not the 8,719,451.50
Slitting_Time_New = SUM(Mfng_Analysis[Hrs])*SUM(Mfng_Analysis[Linear_Footage_Out])
This is due to evaluation context. When using the SUM function, DAX has no row context, unless you actively provide it in a visual table, i.e. for the Total row in your table [Slitting_Time_New] will evaluate
(2,000+2,900+0,800)x(226795+1136807+166127).
What you want to do, I guess, is
(2,0000x226795)+(2,900x1136807)+(0,800x166127)
In order to do that you have to provide row context. This you can do with an aggregator function, such as SUMX.
Slitting_Time_New =
SUMX(
Mfng_Analysis;
[Hrs]*[Linear_Footage_Out]
)
Is it possible to have a range of values in a cell so that Sheets understands it when calculating something?
Here's an example of the desired output:
A B C
1 Value Share Total sum
2 100.00 90-110% 90-110
Here, Total sum (C2) = A2 * B2 (so 100 * 90-110%), giving a range of 90-110.
However, I don't know how to insert this range of values into a cell without Sheets saying #VALUE!.
you will need to do it like this:
=REGEXREPLACE((A2*REGEXEXTRACT(B2, "\d+")%)&"-"&
A2*REGEXEXTRACT(B2, "-(\d+%)"), "\.$", )
for decimals:
=REGEXREPLACE((A40*REGEXEXTRACT(B40, "\d+.\d+|\d+")%)&"-"&
A40*REGEXEXTRACT(B40, "-(\d+.\d+%)|-(\d+%)"), "\.$", )
Sup, simple question ( i hope). I am adding a custom column in Power bi. I need to subtract time values, using custom column formula. Problem: (B-A)-C causes error.
Values are set to time type.
B = 15.00.00
A = 9.00.00
C = 0.05.00
custom column formula:
=([B]-[A])-[C]
Result i want: 5.55.55
Result i get:
Expression.Error: We cannot apply operator - to types Duration and Time.
Details:
Operator=-
Left=0.06:00:00
Right=0.05.00
So B-A = 0.06:00:00 and therefore 0.06:00:00 - 0.05.00 = error. I need to get B-A result in shape of 06.00.00 so i can subtract value C from it. Any suggestions?
Assuming your table is called "Table":
First, create a new column and calculate the difference of B and A.
Col1 = DATEDIFF(Table1[B],Table1[A],HOUR)
Then create another column and subtract C from it.
Col2 = DATEDIFF(Table1[Col1],Table1[C],HOUR)
Can someone pl tell me what is rolling sum and how to implement it in Informatica?
My requirement is as below:(Given by client)
ETI_DUR :
SUM(CASE WHEN AGENT_EXPNCD_DIM.EXCEPTION_CD='SYS/BLDG ISSUES ETI' THEN IEX_AGENT_DEXPN.SCD_DURATION ELSE 0 END)
ETI_30_DAY :
ROLLING SUM(CASE WHEN (SYSDATE-IEX_AGENT_DEXPN.ROW_DT)<=30 AND AGENT_EXPNCD_DIM.EXCEPTION_CD = 'SYS/BLDG ISSUES ETI'
THEN IEX_AGENT_DEXPN.SCD_DURATION ELSE 0 END)
ETI_30_DAY_OVRG :
CASE WHEN ETI_DUR > 0 THEN
CASe
WHEN ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 29 DAYS) BETWEEN 0 AND 600 AND ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 29 DAYS) + ETI_DUR > 600 THEN ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 30 DAYS) - 600
WHEN ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 29 DAYS) > 600 THEN ETI_DUR
ELSE 0 END
ELSE 0 END
And i have implemented as below in Informatica.
Expression Transformation:
o_ETI_DUR-- IIF(UPPER(EXCEPTION_CD_AGENT_EXPNDIM)='SYS/BLDG ISSUES ETI',SCD_DURATION,0)
o_ETI_29_DAY-- IIF(DATE_DIFF(TRUNC(SYSDATE),trunc(SCHD_DATE),'DD') <=29 AND UPPER(EXCEPTION_CD_AGENT_EXPNDIM) = 'SYS/BLDG ISSUES ETI' ,SCD_DURATION,0)
o_ETI_30_DAY -- IIF(DATE_DIFF(TRUNC(SYSDATE),trunc(SCHD_DATE),'DD') <=30 AND UPPER(EXCEPTION_CD_AGENT_EXPNDIM) = 'SYS/BLDG ISSUES ETI' ,SCD_DURATION,0)
Aggregator transformation:
o_ETI_30_DAY_OVRG:
IIF(sum(i_ETI_DUR) > 0,
IIF((sum(i_ETI_29_DAY)>=0 and sum(i_ETI_29_DAY)<=600) and (sum(i_ETI_29_DAY)+sum(i_ETI_DUR)) > 600,
sum(i_ETI_30_DAY) - 600,
IIF(sum(i_ETI_29_DAY)>600,sum(i_ETI_DUR),0)),0)
But is not working. Pl help ASAP.
Thanks a lot....!
Rolling sum is just the sum of some amount over a fixed duration of time. For example, everyday you can calculate the sum of expense for last 30 days.
I guess you can use an aggregator to calculate ETI_DUR, ETI_30_DAY and ETI_29_DAY. After that, in an expression you can implement the logic for ETI_30_DAY_OVRG. Note that you cannot write an IIF expression like that in an aggregator. Output ports must use an aggregate function.
Here is a rolling sum example:
count, rolling_sum
1,1
2,3
5,8
1,9
1,10
Basically it is the sum of the values listed previously. To implement it in Informatica use 'local variables' (variable port in expression transformation) as follows:
input port: count
variable port: v_sum_count = v_sum_count + count
output port: rolling_sum = v_sum_count
we have a moving sum function defined in Numerical functions in Expression transformation:
MOVINGSUM(n as numeric, i as integer, [where as expression]).
Please check if it helps.