Group by calculated column?
How can one group by a colum that is derived? E.g.
select
a.col1,
a.col2,
(select count(*) from table_b b where b.ix=a.ix) as foo,
count(*)
from
table_a a
group by ??????
Unlike "order by" I cannot simply "group by 1,2,3", and calling out the volumn alias "foo" doesn't work either.
SELECT a.col1
, a.col2
, SUM(DECODE(b.ROWID,NULL,0,1)) foo
, COUNT(*)
FROM table_a a
, table_b b
WHERE a.ix = b.ix (+)
GROUP BY a.col1
, a.col2
/
Similar Messages
-
Group By Calculated Columns Issue
Dear All,
I have some lists and libraries which has some calculated columns for calculating year and month based on created date and we have custom views which has group by on those calculated columns. The problem is group by is not working as expected. Attached are
the screens for reference. We have also applied the June CU still no luck.
Please help us on the resolution to the same.
Rajani.JMake sure you dont have space in the data by any chance. You can try recreating the view again.
Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
INSQLSERVER.COM
Mohammad Nizamuddin -
Grouping By a Calculated Column Issue
Hi,
I have 2 issues when I try to group by a view using a calculated column:
It will show the number of items under each group but you expand is not showing any items at all
It will show the item reproduced 333 times.
The first one it happens to all the lists and libraries on SharePoint 2013. However the second issue happened only in a document library that holds the employee Documents. The view is grouped by Document type column and the Employee column ( which is the
calculated column). It shows multiple versions of the same document as stated above.
Any help is very much appreciated.
ThanksHi,
According to your description, there is an issue when grouping by Calculated column.
It was a known issue in the early build version of SharePoint 2013, it is already fixed in the August 2013 CU:
http://blogs.technet.com/b/steve_chen/archive/2013/03/26/3561010.aspx
I suggest you install August 2013 CU or the later versions and then create new list for a test.
Best regards
Patrick Liang
TechNet Community Support -
Group By on Calculated Columns Issue
Dear All,
I have some lists and libraries which has some calculated columns for calculating year and month based on created date and we have custom views which has group by on those calculated columns. The problem is group by is not working as expected. Attached are
the screens for reference. We have also applied the June CU still no luck.
Please help us on the resolution to the same.
Rajani.JHi Rajani,
can you please paste your calculated formula here? Try this formula =TEXT(Created,"yyyy")&TEXT(Created,"mm") to check it is working correctly with numeric month or not?
Thanks. -
I am trying to learn HANA on my own.i have product id,product name,delivery date and Grossamount in my calculated view.i am trying to create calculated column where i need Grossamount in two columns based on delivery date.I have 2012 and 2013 as values for my delivery date.so i have created two column as grossamount_2012 and grossamount_2013.if i have delivery date as 4thdec,2012 i want the grossamount value to be in coloumn grossamount_2012 and the grossamount_2013 should be blank.i have written an expression like this
if("Deliverydate" <= longdate(2012-12-04),"Grossamount","0")
and it looks like this is wrong.i am getting the text Grossamount rather than values for that field in my output.so can anyone help me please?Hi chandra
i am trying to get the same result by using sql script and CE functions.i have written the following code
select A."PRODUCTID",
E."TEXT" as "PRODUCTNAME",
C."COUNTRY",
D."DELIVERYDATE",
Sum(D."GROSSAMOUNT") as "GROSSAMOUNT"
from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Products" as A
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.BusinessPartner" as B
on A."SUPPLIERID" = B."PARTNERID"
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses" as C
on B."ADDRESSID" = C."ADDRESSID"
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.Purchase.Item" as D
on A."PRODUCTID" = D."PRODUCTID"
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.Util.Texts" as E
on A."NAMEID" = E."TEXTID"
GROUP BY A."PRODUCTID",E."TEXT",C."COUNTRY",D."DELIVERYDATE";
this is working fine but i want to split the grossamount based on current year and last year.Any idea how to do this
In calculation view using script can we use if and case statements? -
How to create a calculated column in sharepoint
I created the custom list in share point. In that list i renamed the title as
Name.
I created the WindowsID as person or group column in share point list.
In the same list, I want to create a new calculated column as EmpName as hyperlink with the below formula
="<a href='"&WindowsID &"'>"&Name&"</a>"
But I am unable to create a new column by using above formula.
Could you please let me know what i missed in the above formula.
Please note that i am unable to see the WindowsID in the insert column.
Thanks for ur support.Hello
Sorry for the delay replay.
Based on your guidance,i followed the below steps
1.created the loginname column of type person or group
2.Added the contentquery webpart
3.crated the custom xslt template
4.Please find the below template
<xsl:template name="ListingItem" match="Row[@Style='ListingItem']" mode="itemstyle">
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LoginID">
<xsl:value-of select="ddwrt:UserLookup(string(@DomainID) ,'User')" />
</xsl:variable>
<div id="membersdiv" class="members">
<!-- <xsl:value-of select="$LoginID" disable-output-escaping="yes"/>-->
<xsl:if test="$LoginID != ''">
<a href="{$LoginID}">
<xsl:value-of select="@Title" disable-output-escaping="yes"/>
</a>
</script>
</xsl:if>
</div>
</xsl:template>
if user is having the login id then i need display the title.on click of that title i need to redirect to user settings page like http://url/_layouts/15/userdisp.aspx?ID=1 .How can i redirect to
the sharepoint personal settings page based on person click -
SharePoint 2013 Make Calculated Column based on Custom Column
In SharePoint 2013, I am trying to create a Calculated Column that is a shortened display of another Custom Column. The Calculated Column would just show the first 100 characters concatenated with "..." like in the following formula:
=LEFT([CustomColumn],100)&"..."
However, every time that I go to create this calculated column, SharePoint doesn't provide my [CustomColumn] in the "Insert Column:" list. If I type it in anyway, SharePoint throws an error.
Details on my Column, List, and Site below:
Col. Type: Multiple lines of text
Col. Group: Custom Columns
Col. Text Type: Enhanced rich text
List Content Type: Custom Type Inherits from Event
Site Type: Publishing
Also, to no avail, I found this similar post (link below), but creating the Site Column and Calculated Column
before adding it to the Content Type did not work for me.
http://social.technet.microsoft.com/Forums/sharepoint/en-US/26a7517e-ba43-4c49-95aa-3e6f7f4207ba/calculated-field-in-content-type-not-working
Anyone out there know how to coax SharePoint into submission?!Multi lines of text are one of the types of columns which can't be used by calculated columns/fields. Among such unusable columns are also Lookup columns, People columns, External Columns, MMS columns, etc.
Scott Brickey
MCTS, MCPD, MCITP
www.sbrickey.com
Strategic Data Systems - for all your SharePoint needs -
Strange error in Discoverer calculated columns.
Hi,
I got a strange error in discoverer10g worksheet. In woksheet the calculated coulmns did not return data but in PL/SQL developer when I run the query taking from the Show SQL of Discoverer Worksheet it returns. Anyone please help me to resolve this problem.
I paste the show sql discoverer query below:
SELECT /*+ NOREWRITE */
O378524.NAME AS E394898,
O397424.COMPANY AS E397430,
O397424.SEGMENT1 AS E397431,
O397424.INV_ORG AS E397433,
O397424.VENDOR_NAME AS E397435,
O397424.INVOICE_ID AS E397436,
O397424.PERIOD_NAME AS E397438,
O397424.AMOUNT_PAID AS E397439,
DENSE_RANK() OVER(PARTITION BY O397424.ORG_ID ORDER BY O397424.AMOUNT_PAID DESC) AS C_5,
(SUM(O397424.AMOUNT_PAID)
OVER(PARTITION BY O397424.ORG_ID ORDER BY O397424.AMOUNT_PAID DESC ROWS
UNBOUNDED PRECEDING)) /
(SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID)) AS C_4,
SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID ORDER BY O397424.AMOUNT_PAID DESC ROWS UNBOUNDED PRECEDING) AS C_1,
O397424.AMOUNT_PAID /
(SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID)) AS C_3,
SUM(O397424.AMOUNT_PAID) OVER(PARTITION BY O397424.ORG_ID) AS C_2
FROM (SELECT * FROM APPS.HR_OPERATING_UNITS) O378524,
(SELECT DISTINCT /*SEGMENT1*/ CODE_COMBINATION_ID, INV_ORG
FROM (SELECT GCC.SEGMENT1,
GCC.CODE_COMBINATION_ID,
DECODE(GCC.SEGMENT1,
7590,
'Kanowna Belle Organisation',
7060,
'Darlot Organisation',
7260,
'Cowal Organisation',
7570,
'Kanowna Belle Organisation',
7595,
'Kundana Organisation',
7070,
'Lawlers Organisation',
7180,
'NULL for Yilgarn(Barrick (Services) Limited)',
7541,
'Granny Smith Organisation',
7015,
'NULL for Barrick Gold(Barrick (Australia Pacific) Limited)',
7610,
'Kundana Organisation',
7014,
'NULL for Yilgarn(Yilgarn Shared Services)',
7538,
'Granny Smith Organisation',
'Unknown') INV_ORG
FROM APPS.GL_CODE_COMBINATIONS GCC)
/*WHERE SEGMENT1 IN
(7590, 7060, 7260, 7570, 7595, 7070, 7180, 7541, 7015, 7610, 7014, 7538)*/
) O394875,
(SELECT CHQ.ORG_ID,
FVT.DESCRIPTION COMPANY,
GCC.SEGMENT1,
INVD.DIST_CODE_COMBINATION_ID,
DECODE(GCC.SEGMENT1,
7590,
'Kanowna Belle Organisation',
7060,
'Darlot Organisation',
7260,
'Cowal Organisation',
7570,
'Kanowna Belle Organisation',
7595,
'Kundana Organisation',
7070,
'Lawlers Organisation',
7180,
'NULL for Yilgarn(Barrick (Services) Limited)',
7541,
'Granny Smith Organisation',
7015,
'NULL for Barrick Gold(Barrick (Australia Pacific) Limited)',
7610,
'Kundana Organisation',
7014,
'NULL for Yilgarn(Yilgarn Shared Services)',
7538,
'Granny Smith Organisation',
'Unknown') INV_ORG,
CHQ.VENDOR_ID,
CHQ.VENDOR_NAME,
COUNT(INV.INVOICE_ID) INVOICE_ID,
--INVL.PRODUCT_TYPE,
INVL.PERIOD_NAME,
--chq.check_date,
SUM(NVL(INVP.PAYMENT_BASE_AMOUNT, INVP.AMOUNT)) AMOUNT_PAID
FROM APPS.AP_CHECKS_ALL CHQ,
APPS.AP_INVOICE_PAYMENTS_ALL INVP,
APPS.AP_INVOICES_ALL INV,
APPS.AP_INVOICE_LINES_ALL INVL,
APPS.AP_INVOICE_DISTRIBUTIONS_ALL INVD,
APPS.GL_CODE_COMBINATIONS GCC,
APPS.FND_FLEX_VALUES FV,
APPS.FND_FLEX_VALUES_TL FVT
WHERE CHQ.CHECK_ID = INVP.CHECK_ID
AND INVP.INVOICE_ID = INV.INVOICE_ID
AND INVL.INVOICE_ID = INV.INVOICE_ID
AND INVL.LINE_NUMBER =
(SELECT MIN(LINE_NUMBER)
FROM APPS.AP_INVOICE_LINES_ALL
WHERE INVOICE_ID = INVL.INVOICE_ID
AND LINE_TYPE_LOOKUP_CODE = 'ITEM'
AND DISCARDED_FLAG = 'N')
AND INVL.INVOICE_ID = INVD.INVOICE_ID
AND INVL.LINE_NUMBER = INVD.INVOICE_LINE_NUMBER
AND INVD.DISTRIBUTION_LINE_NUMBER = 1
AND INVD.DIST_CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
AND FV.FLEX_VALUE_SET_ID = 1013043
AND FV.FLEX_VALUE = GCC.SEGMENT1
AND FV.FLEX_VALUE_ID = FVT.FLEX_VALUE_ID
GROUP BY CHQ.ORG_ID,
GCC.SEGMENT1,
CHQ.VENDOR_ID,
CHQ.VENDOR_NAME,
FVT.DESCRIPTION,
--INVL.PRODUCT_TYPE,
INVL.PERIOD_NAME,
--chq.check_date,
INVD.DIST_CODE_COMBINATION_ID) O397424
WHERE ((O397424.ORG_ID = O378524.ORGANIZATION_ID) AND
(O397424.DIST_CODE_COMBINATION_ID = O394875.CODE_COMBINATION_ID))
AND (O397424.AMOUNT_PAID > 0)
AND (O397424.PERIOD_NAME = /*:"Period"*/'DEC-09')
-- AND (O394875.INV_ORG = :"Inv Org")
AND (O378524.NAME = /*:OU*/'Barrick Yilgarn')
ORDER BY O397424.AMOUNT_PAID DESC;
Edited by: Soma Sekhar D on Feb 24, 2010 11:46 AMHi,
In the report I have two worksheet. The Ist worksheet has the same calculated columns as 2nd worksheet. Even the calculations are also the same. The only difference is I use different folder for the 2nd worksheet. For 2nd worksheet layout only the calculated columns will not display the result.The other columns displayed the result properly. Even in the Ist worksheet all the columns including calculated columns displayed the result correctly.The calculations are same in the 2nd worsheet with calculation names different and items coming from different folder. As these calculations are working properly in Ist worksheet,why its not appearing in the 2nd worksheet? The query I paste before is the Discoverer show sql query for 2nd worksheet.
Please help. -
Calculated column doesn't expand the items in list view
Dear All,
I have a calculated column
Week with formula, =INT((DAY([Start Time])+6)/7)
in one of my lists. I'm displaying a view of this list in a SharePoint page, group by column Year and column
Week. But when the page is loaded with items, I'm only able to expand the list view up to
Year column level. When I click on Week section it doesn't show / expand the items under it.
Further more when I use a different calculated column with a function like (=TEXT(Date,"yyyy")) I don't get above error.
Any Idea?
Thanks,
DilipHi Dilip,
According to your description, an issue occurs when you try to expand the subgroups in a list contains Calculated column.
It is an known issue in SharePoint 2013, there are some workarounds I can provide as below:
As the first workaround, you can set the groupings to expanded by default, though it would make the grouping collapsed by default, then the grouping would function
normal.
As the second workaround, you can create a SharePoint Designer Workflow and add a “Do Calculation” action to calculate the value you needed. Then add a “Update List
Item” action to add the value to a “Single line of text” column. We will use the “Single line of text” column in the grouping instead of the Calculated column.
As the third workaround, you can install the latest update of SharePoint to fix the issue for new Document Libraries. For the existing libraries, after the installing
the update, you can use PowerShell to make an update to each item in the library, it will make the old items get normal in the grouping.
About how to update list items in a list/library using PowerShell, a demo as below for your reference:
$web = Get-SPWeb http://YourServer/
$list = $web.Lists["list name"]
foreach ($item in $list.Items)
$item.SystemUpdate();
Best regards
Patrick Liang
TechNet Community Support -
Problem with binding value on the UI from a calculated column in the view
I have calculated field "Readiness" in my db view, which gets calculated based on other columns in the same table. I have added new column to my EO using "Add from table" option and added the same column from to VO using "Add from EO" option. In my application, I will update a particular date field in the UI and this calculated column "Readiness" in the db will be set to yes or no and this logic is working fine, both date date field and calculated field are in same view object. I have added a attribute binding to this "Readiness" column in my view page. The problem is the calculated column value does not reflect the new value in the db, it shows the old value. I have tried different refresh option for the iterator and ppr option for the field binding. Even after reloading the page, the value shown on the UI page is different from the value in db, other bindings on the UI page works fine, not sure any special settings are required for the Calculated columns. any ideas are appreciated.
Thanks for your help,
SuryaI tried to add soms debugging statements in the EO and getters method, the calcaulated column is not picking the value in db view. I'm not any special iterator/field settings are required at BC level. I'm a newbie, any help is appreciated.
Thanks,
Surya -
Calculated Column using IF statement with DATEIF formula
I have a dated column that includes a date when a position is vacated otherwise the field is blank if the position is still filled. I want a calculated column to return the number of days the position has been vancant from the date that is listed to today.
So the following was entered & works.....
=DATEDIF([Vacancy Date],Today,"d")
The delima is that it is also returning a value when there is no date in the dated column but it returns a funky number 42,069. What I want it to return when the dated column is blank is blank or zero would work too. I don't know how to incorporate that
into this formula.You are correct it no longer reads that column as Today.... So is there anyway to make this a calculated column for my purposes?
I'm going to use SharePoint list for a Position Pool & managing positions within a large department. What I'm attempting to do with this column is have a current count of the number of days since a position has been vacant. Our system that I pull the
position data from will give me the vacancy date for those positions & where the position is filled the date field will be blank. So I'm wanting this column to return a 0 when the position is listed as filled & the number of days vacant based on the
vacancy date column I have. Is there any way to make this work in SharePoint? Obviously I can make that work in Excel however my task was to load raw data into SharePoint & have SharePoint do the work if possible with little to no human intervention prior
to loading to SharePoint.
Thank you,
MMHagman -
DAX - IF statement and filters within calculated column
Hi all,
I've got a bit of a complex formula I'm trying to run, but I'm not quite there yet. I don't know where/how/if I can place a filter within my IF statement for a calculated column due to so many variables. I either get errors or wrong numbers.
Hope the following makes sense.
Here is my formula for the calculated column [Years Since Last Task]:
=IF (ISBLANK([Last Task Date]) && ([Current Role]<>BLANK()), DIVIDE([Quarters],4), FLOOR(1. * ( today() - [Last Task Date]) / 365, 0.25))
Problem: I am getting "114.25" for Ken....but I want a blank result instead. Meaning, I need to also filter out any name (row) who has a blank [Current Role]. How do
I add a filter to this current formula? Is one more step of filtering possible in this IF statement? (Maybe I shouldn't use an IF statement, and try CALCULATE instead?)
Below is the table 'Work' for you to see what's happening.
Name
Quarters
Last Task Date
Current Role
Years Since Last Task
John
1
1
0.25
Mike
4
2/7/2011
3
3
Todd
5
4/20/2009
4
5
Jeff
9/1/2013
3
0.5
Ken
0
114.25
Steve
2
12/3/2011
2
2.25
Nate
2
1/1/2014
2
0.25
Greg
1
8/11/2013
1
0.5
Ross
4
11/9/2010
4
3.25
Hope all this made sense. Let me know if you have any thoughts.
Thanks,
~UG1you can use nested IF-statements here:
=IF (ISBLANK([Current Role]),
BLANK(),
IF(ISBLANK([Last Task Date]),
DIVIDE([Quarters],4),
FLOOR(1. * ( today() - [Last Task Date]) / 365,0.25)
hth,
gerhard
Gerhard Brueckl
blogging @ http://blog.gbrueckl.at
working @ http://www.pmOne.com -
Creating a Status column (IF statement/calculated column)
I'm developing list for managing a project with 11 columns each representing a project milestone.
We'll call them A,B,C...K.
"A" representing a status of "Project Started" and K representing "Project Complete" with various statuses in between.
When a milestone has been reached, the date is input into the appropriate column. So when the project is complete, there will be dates in all columns A-K
I wish to incorporate a new column that indicates the current status depending on if columns A-K have been filled in.
So if all columns are blank, a status of "Awaiting start" is indicated.
If column A is filled in with a date, a status of "A" is indicated.
If columns A and column B are filled in then a status of "B" is indicated.
If columns A, B and C are filled in then a status of "C" is indicated. * * If all the columns are filled in with dates, a status of "K" is indicated.
Any ideas? Some form of If statement in a calculated Status column?Hello,
You can use nested if statement something like below.
For example, I have one column named as 'Score' and the requirement is to perform quartile breakup based on score so for that I can use below calculated formula in my calculated column.
=IF(INT(Score)>85,"85 Above"
,IF(AND(85>=INT(Score),INT(Score)>=80),"85-80"
,IF(AND(79>=INT(Score),INT(Score)>=75),"79-75"
,IF(INT(Score)<75,"Below 75","0"))))
Have below links for more details.
Calculated Field Formulas
Examples of common formulas
Thanks. Please mark it as an answer if it helped. -
CASE statement in Calculated column
Hi Frzz,
I have below requirement in Calculated column with CASE statement. Could some one help me how to achieve this with case statement.
String = 0Hello
01Hello
012Hello
0123Hello
If 1st Character of the string is '0' then - 0Hello
1st 2 characters of the String is '01' - 22Hello
1st 3 characters of the String is '01' - 333Hello
1st 4 characters of the String is '01' - 4444Hello
Thank you.
Best Regards,
Krishna.Hi Krishna ,
Using IF and MATCH to do that: ( I took one of the conditions you specified )
IF(match("STRING1",'??0??'),'333Hello',"STRING1")
Output:
Regards,
Krishna Tangudu -
If statement for calculated column
Hi, I need to know if its possible to do the following in a calculated column
if column1 value => 1
display the name of column1 + the value of column 1
is this possible?Hi hein,
You can return your calculated column value as "Number" type, set the "blank space" in your formula, see the formula as follow,
=IF([A4 Printing Paper Box]>0,"[A4 Printing Paper Box]"&[A4 Printing Paper Box]," ")
http://msdn.microsoft.com/en-us/library/bb862071.aspx
Thanks
Daniel Yang
TechNet Community Support
Maybe you are looking for
-
Multiple iphones using one itunes account
I'm fairly new to the itunes world and was wondering about the ability to sync multiple iphones to a single itunes account. I have the iphone 4s and have it synced with my itunes account...my boyfriend recently left the dark ages and is now using my
-
Use one store account for two I pads. Get request for security code
Trying to use one store account for two I pads. One works fine, the other is unable to download a free app, window asks for security code.?....... What security code?
-
How to add to java classpath?
I am wondering how to add/implement to java classpath. I think I might be missed out the classpath thing so my program doesn't work. I keep getting error message like: "cannot resolve symbol: method setDocumentHandler(BookCounter)" and warning messag
-
Switching windows in Linux/Firefox loses keyboard focus. Workarounds?
Hi, I've been stumbling on an issue in which an applet gets into a state where it can receive mouse events but not keyboard events. This state occurs some of the time when switching from a non-modal dialog to the applet. I've witnessed this behavior
-
Need software for airport extreme for 10.2.8
Hi, I just bought a airport extreme card, but it says I cannot install the software b/c I need yo have Mac OS X 10.3.3. I have 10.2.8 on my system. Anyone know where I can download this? I've searched with no success...thanks!