Can't find the error in formula - the value is calculated throughout the column (when keeping errors - no rows shown), but I can't apply the changes though.((
if [Index] > 0 then
if articles_pivot{[Index]-1}[IN] <> null (when omitted the error remains) and [IN]=null then
articles_pivot{[Index]-1}[IN]
else null
else null
Thank you for advice!
If I an reading it right, all you really need to do is right click IN column and do fill ... down...
Otherwise, see if this works
= try if articles_pivot{[Index]-1}[IN] <> null and articles_pivot{[Index]}[IN] = null then articles_pivot{[Index]-1}[IN] else null otherwise null
decided to make it another way - in the origin table I've added Index column starting 0 and in the pivot table (made by pivoting the origin one) I've added index column starting 1, then merged them..)
Related
I write this query I dont know why its not working for me can anyone suggest for me which is right
SELECT MAX(NVL(CPV.SR_NO,0)+1) INTO :CPV.SR_NO FROM CPV
WHERE VOUCHER_ID=4;
I have to bring MAX value I put 0 but it never bring 1 for first record after one record it worked properly mean if table is empty then first entry not give 1 after one record saved than its showed 1 even nvl is shown to null to 0 then + 1 please correct me
thanks
If there are no rows with VOUCHER_ID = 4, then you are taking MAX over zero rows, and that is always NULL - it doesn't matter what expression you are taking the MAX over. The NVL you used will only have effect if there are rows with VOUCHER_ID = 4, but in those rows you may have NULL in the SR_NO column. It won't help if there are no rows to begin with.
You could write the code like this **:
SELECT MAX(SR_NO) INTO :CPV.SR_NO FROM CPV WHERE VOUCHER_ID=4;
:CPV.SR_NO := NVL(:CPV.SR_NO, 0) + 1;
That is - apply the NVL (and also add 1) outside the SELECT statement.
With that said - what is the business problem you are trying to solve in this manner? It looks very much like an extremely bad approach, no matter what the problem you are trying to solve is.
** Note - I haven't seen qualified bind variable names before, like :CPV.SR_NO, but since the query works for you, I assume it's OK. EDIT - I just tried, and at least in Oracle 12.2 such names are invalid for bind variables; so I'm not sure how it was possible for your code to work as posted.
ANOTHER EDIT
The whole thing can be simplified further. We just need to pull the NVL out of MAX (and also the adding of 1):
SELECT NVL( MAX(SR_NO), 0) + 1 INTO :CPV.SR_NO FROM CPV WHERE VOUCHER_ID=4;
i have 2 tables which have 2 relationships based on 2 dates :
The "daily_valus" table have several products per date which (date) is connected to the weeklies table on the 2 dates (date fin adjusted & date début adjusted). The "date début adjusted" is the active one.
I have the following formula in a new column (ctRow) of the weeklies table :
= calculate( COUNTROWS(daily_valus); USERELATIONSHIP(daily_valus[Détail.Date];weeklies[date fin adjusted]))
The formula works and is getting the right number of rows.
However, I have another add. column and i'm just refererencing the ctRow column :
= weeklies[ctRow]
then i got that error below.
Does anyone knows why ?
It should be enough to remove the dependency from all of the columns but for the date to be used in the relationship using ALLEXCEPT
=
CALCULATE(
COUNTROWS( daily_valus );
USERELATIONSHIP ( daily_valus[Détail.Date]; weeklies[date fin adjusted] );
ALLEXCEPT( weeklies; weeklies[date fin adjusted] )
)
Edit:
The circular dependency happen because when we use CALCULATE, a context transition happens, to transform the current row context on the current rows for which we are evaluating the calculated column.
This means that a filter context is set on every column of the current row, including the second calculated column, that copies the ctRow, that I'll call ctRow2. But ctRows2 depends on ctRow, therefore we get the circular dependency.
To solve the circular dependency we must remove the dependency from the result of the context transition, but keeping the filter over the column that is needed for the relationship to work, that in our case it means to use ALLEXCEPT( weeklies; weeklies[date fin adjusted] ).
I managed to solve similar error by removing USERELATIONSHIP line, which was not needed in my case. So one solution should be to make the connection active and then remove this line.
I want to create a calculated column that increments by 1 every time it meets a true in bool column. any ideas ?
in the image at left is the data table and at right the desired result
Something like the formula below should work
case when [bool]=True then sum(If([bool]=True,1,0)) over (AllPrevious([id])) else 0 end
I got this selection of data from my sql:
I would like to add Cancelled, Disputed and Resolved together and then divide the result with the total shipped. All of this should be done with an Expression.
So x / 303 where x is the sum of the desired values.
Goal would be to get a % where I can tell how good my shipping is.
I would then like to display the result in a text label next to a graph.
How do I do that?
You should use computed columns in your data set:
Add a SUM on the column Total and a filter only matching the rows based on the column Status you want to select. The expression should look like:
if (row["Status"] == "Cancelled" || row["Status"] == "Disputed"
|| row["Status"] == "Resolved")
true
else
false
create a second computed column only containing the "Total" value where the Status is Shipped.
if (row["Status"] == "Shipped")
row["Total"]
Then create a third computed column where you divide both computed values and you are done.
row["sum"] / row["shipped"]
create a new parameter and refer the image
create new static values and allow multiple values to be selected.
So, accordingly edit your SQL queries
Trying to get the [Number] and [Sum of Time Spent] for all Changes that were open during period 201405.
The best definition of open I can think of is is:
- Changes that were logged before or during the [MonthPeriod], while closed during or after the [MonthPeriod]
SELECT
[Measures].[Sum of Time Spent] ON COLUMNS
,
[FactChange].[Number].[Number] ON ROWS
FROM
[Change Management]
WHERE
(FILTER(
[DimLoggedDate].[MonthPeriod].[MonthPeriod]
,[DimLoggedDate].[MonthPeriod].MEMBERVALUE <= 201405
)
,
FILTER(
[DimClosedDate].[MonthPeriod].[MonthPeriod]
,[DimClosedDate].[MonthPeriod].MEMBERVALUE >= 201405
))
The above query returns a list with all numbers, with a null value when the filters in the WHERE clause don't apply. I would like to remove the NULL items.
Because the query returns ALL Numbers, I wonder if this is the most efficient query to solve the issue. Applying NonEmpty() would remove the numbers, but since all changes are enumerated, isn't this putting more stress on the system than required?
You do it simply by adding "Non empty" in the on Rows clause:
...
non empty [FactChange].[Number].[Number] on Rows
...