บทความนี้จะอธิบายถึงวิธีการใช้งาน Function Getdate() ใน MDX Query
ปกติหากจะหาวันที่ปัจจุบันใน SQL Server จะใช้ Function Getdate() และจัด Format ตามต้องการ
เช่น SELECT Convert(char(8),Getdate(),112)
แต่หากเป็นใน MDX Quey แล้ว จะแตกต่างกันไปนิดหน่อยโดยใช้ Function NOW() แทนครับ
ดูตามตัวอย่าง และนำไปประยุกต์ใช้เอาตามชอบใจ
WITH
MEMBER [Measures].[CurYear] as -- Current Year (Full)
Format(NOW(), "yyyy" )
MEMBER [Measures].[CurYearShot] as -- Current Year (With 2 digits)
Format(NOW(), "yy" )
MEMBER [Measures].[CurMonthFull] as -- Current Month (Full)
Format(NOW(),"MMMM")
MEMBER [Measures].[CurMonthNum] as -- Current Month (With 2 digits)
Format(NOW(),"MM")
MEMBER [Measures].[CurDateNum] as -- Current Date (With 2 digits)
Format(NOW(),"dd")
MEMBER [Measures].[CurDateFull] as -- Current Date
Format(NOW(),"d")
MEMBER [Measures].[CurDateFullFormat] as -- Current Date (With custom format)
Format(NOW(),"dd/MM/yyyy")
MEMBER [Measures].[PrvYear] as -- Previous Year
Format(DATEADD("yyyy",-1,NOW()),"yyyy")
MEMBER [Measures].[NxtYear] as -- Next Year
Format(DATEADD("yyyy",1,NOW()),"yyyy")
MEMBER [Measures].[PrvMonth] as -- Previous Month
Format(DATEADD("m",-1,NOW()),"MMMM")
MEMBER [Measures].[NxtMonth] as -- Next Month
Format(DATEADD("m",1,NOW()),"MMMM")
MEMBER [Measures].[PrvDate] as -- Previous Day
Format(DATEADD("d",-1,NOW()),"dd")
MEMBER [Measures].[NxtDate] as -- Next Day
Format(DATEADD("d",1,NOW()),"dd")
MEMBER [Measures].[YearDiff] as -- Difference between 2 years
DATEDIFF("yyyy",DATEADD("yyyy",-1,NOW()),DATEADD("yyyy",3,NOW()))
MEMBER [Measures].[ConvertStrToDate] as -- Convert String to Date
Cdate("1/28/2010")
select {[Measures].[CurYear],[Measures].[CurYearShot],[Measures].[CurMonthFull],[Measures].[CurMonthNum],
[Measures].[CurDateNum],[Measures].[CurDateFull],[Measures].[CurDateFullFormat],
[Measures].[PrvYear],[Measures].[NxtYear],[Measures].[PrvMonth],[Measures].[NxtMonth],
[Measures].[PrvDate],[Measures].[NxtDate], [Measures].[YearDiff],
[Measures].[ConvertStrToDate]} ON 0
FROM [Adventure Works]
Mssql, Microsoft sql server, SSAS, SSRS ,SSIS , Analysis Service, Reporting Service, Integration Service, XMLA ,MDX ,SQL
วันจันทร์ที่ 26 เมษายน พ.ศ. 2553
วันอังคารที่ 20 เมษายน พ.ศ. 2553
Process OLAP dimensions error , "File system error: A FileStore error from WriteFile occurred. Physical file"
Error issued because "PROCESS UPDATE" large dimensions.
-------------------------------------------------------------
Event Type: Error
Event Source: SQLISPackage
Event Category: None
Event ID: 12550
Date: 4/18/2010
Time: 10:06:35 PM
User: OLAP-SERVER\SQLService
Computer: OLAP-SERVER
Description:
Event Name: OnError
Message: File system error: A FileStore error from WriteFile occurred. Physical file: \\?\E:\ Projects\OLAP\Data\olap_tsc301.0.db\Dim Card.14.dim\77.Dim Card.bsstore. Logical file: . .
Operator: MyServer\SQLService
Source Name: Process OLAP_TSC301 DIM
Source ID: {2cf2f9b3-07fb-490a-abca-eb7cf83c1c2b}
Execution ID: {D0810E33-4776-4B32-A15E-107267F343C4}
Start Time: 4/18/2010 10:06:35 PM
End Time: 4/18/2010 10:06:35 PM
Data Code: -1056833471
--------------------------------------------------------------------------
It happen when your dimension file is growth over 4GB.
And you choose PROCESS UPDATE method to process dimensions.
I have errors issued and found on google search ,
to solve problem is FULL Process Cube for a moment. And I don't have a permanent solution to fix this problem.
-------------------------------------------------------------
Event Type: Error
Event Source: SQLISPackage
Event Category: None
Event ID: 12550
Date: 4/18/2010
Time: 10:06:35 PM
User: OLAP-SERVER\SQLService
Computer: OLAP-SERVER
Description:
Event Name: OnError
Message: File system error: A FileStore error from WriteFile occurred. Physical file: \\?\E:\ Projects\OLAP\Data\olap_tsc301.0.db\Dim Card.14.dim\77.Dim Card.bsstore. Logical file: . .
Operator: MyServer\SQLService
Source Name: Process OLAP_TSC301 DIM
Source ID: {2cf2f9b3-07fb-490a-abca-eb7cf83c1c2b}
Execution ID: {D0810E33-4776-4B32-A15E-107267F343C4}
Start Time: 4/18/2010 10:06:35 PM
End Time: 4/18/2010 10:06:35 PM
Data Code: -1056833471
--------------------------------------------------------------------------
It happen when your dimension file is growth over 4GB.
And you choose PROCESS UPDATE method to process dimensions.
I have errors issued and found on google search ,
to solve problem is FULL Process Cube for a moment. And I don't have a permanent solution to fix this problem.
I had this problem many times, until I found a totally unrelated article pertaining to a 4 GB limitation for the .asstore file in MOLAP dimensions. I talked to Microsoft, and they investigated and found that the limitation does exist. If it happens again, I would suggest browsing the data folder where the database exists and opening the failing dimension folder. If you see that the dimension file with a .asstore extension, or any other one that is over 4 GB, you have found your problem. There is nothing short of doing a full process on the dimension (which the Microsoft guy suggested, and I had to yell at him (in a nice way)) when it hits the limit. If you MUST Process Update and you cannot use ProcessAdd on your dimension, I would suggest breaking the dimension in a linear fashion into several dimensions (column by column), or finding a new way to build the dimension where it will not grow exponentially. A Process Update appends string data to the file, and that is why it gets so large. I would also suggest taking a look at the AS dimension and see if there are any character columns you can cut down in size.Ref site. http://geekswithblogs.net/darrengosbell/archive/2007/04/29/SSAS-ProcessUpdate---Too-much-of-a-good-thing.aspx
วันจันทร์ที่ 5 เมษายน พ.ศ. 2553
Faulting application excel.exe, version 12.0.6425.1000, stamp 49d64dd6, faulting module msvcrt.dll
Faulting application excel.exe, version 12.0.6425.1000, stamp 49d64dd6, faulting module msvcrt.dll
Excel 2007 crash.
Just run regedit and goto
HKEY_Local_Machine\Software\Microsoft\Office\Excel\Addins
then set a BtOfficeAddin.BtOfficeIntegration.1 LoadBehaviour to 0.
Excel 2007 crash.
Just run regedit and goto
HKEY_Local_Machine\Software\Microsoft\Office\Excel\Addins
then set a BtOfficeAddin.BtOfficeIntegration.1 LoadBehaviour to 0.
วันศุกร์ที่ 2 เมษายน พ.ศ. 2553
MDX Query : Select Except members
MDX Query syntax for "NOT IN" or "Except" condition
มีทริ๊กเล็ก เกี่ยวกับการใช้ MDX ในการ Selelect ข้อมูลให้ได้ตามต้องการ ในที่นี้หากเทียบกับใน SQL
แล้วก็คือการใช้ IN หรือ NOT IN นั่นเอง
ตัวอย่าง MDX สำหรับ Condition NOT IN : Using AdventureWork
---------------Normal condition -------------------
ตัวอย่าง Query สำหรับการเรียกดูยอดขายของสินค้าทุกประเภท
SELECT [Measures].[Sales Amount] on 0,
[Product].[Category].[Category] ON 1
FROM [Adventure Works]
Result
Sales Amount
Accessories $1,272,057.89
Bikes $94,620,526.21
Clothing $2,117,613.45
Components $11,799,076.66
-------- EXCEPT or NOT IN condition ---------
SELECT [Measures].[Sales Amount] on 0,
-{[Product].[Category].&[1],[Product].[Category].&[4]} on 1
FROM [Adventure Works]
Result
Sales Amount
Clothing $2,117,613.45
Components $11,799,076.66
จากตัวอย่างจะเห็นว่าผลลัพธ์เหลือแค่ 2 rows คือ Clothing และ Component
Categories ที่หายไปคือ Accessories และ Bikes ซึ่งเกิดจากการที่เราได้ใส่ Except / Not in
เข้าไปใน Query นั่นเอง ซึ่งรูปแบบคือ -{member set}
มีทริ๊กเล็ก เกี่ยวกับการใช้ MDX ในการ Selelect ข้อมูลให้ได้ตามต้องการ ในที่นี้หากเทียบกับใน SQL
แล้วก็คือการใช้ IN หรือ NOT IN นั่นเอง
ตัวอย่าง MDX สำหรับ Condition NOT IN : Using AdventureWork
---------------Normal condition -------------------
ตัวอย่าง Query สำหรับการเรียกดูยอดขายของสินค้าทุกประเภท
SELECT [Measures].[Sales Amount] on 0,
[Product].[Category].[Category] ON 1
FROM [Adventure Works]
Result
Sales Amount
Accessories $1,272,057.89
Bikes $94,620,526.21
Clothing $2,117,613.45
Components $11,799,076.66
-------- EXCEPT or NOT IN condition ---------
SELECT [Measures].[Sales Amount] on 0,
-{[Product].[Category].&[1],[Product].[Category].&[4]} on 1
FROM [Adventure Works]
Result
Sales Amount
Clothing $2,117,613.45
Components $11,799,076.66
จากตัวอย่างจะเห็นว่าผลลัพธ์เหลือแค่ 2 rows คือ Clothing และ Component
Categories ที่หายไปคือ Accessories และ Bikes ซึ่งเกิดจากการที่เราได้ใส่ Except / Not in
เข้าไปใน Query นั่นเอง ซึ่งรูปแบบคือ -{member set}
วันอังคารที่ 30 มีนาคม พ.ศ. 2553
การพิมพ์ Label จาก Crystal report
การกำหนดขนาดกระดาษสำหรับ Print Label ใน Crystal report
การพิมพ์ Label จาก Crystal report โดยใช้กระดาษต่อเนื่องที่มีขนาดเล็กนั้นอาจมีปัญหาว่า
สร้าง Form กระดาษให้ตรงตามจริงแล้ว ตอนสั่งพิมพ์ไม่สามารถเลือกฟอร์มกระดาษที่กำหนดขึ้นได้
กรณีที่เคยพบคือ ใช้เครื่องพิมพ์ EPSON LQ 2180i พิมพ์ Label แปะซองจดหมายถึงลูกค้า แต่ขนาดของ
Label มีขนาด Width : 11 cm และ Height : 3.5 cm ซึ่งเครื่องขนาดของฟอร์มกระดาษเล็กกว่าขนาดที่
เล็กที่สุดที่เครื่องพิมพ์รองรับทำให้เครื่อง Printer ไม่สามารถ Detect เจอ size กระดาษนั้นได้
จึงได้โทรไปสอบถามทาง Epson ถึงวิธีการแก้ไข จึงได้ทราบวิธีที่ง่ายมาก คือเพียงแต่เปลี่ยนไปใช้
Driver ของเครื่องพิมพ์รุ่นที่เก่ากว่า ก็จะทำให้สามารถสั่งพิมพ์ลงใน Form ที่มี ขนาดเล็กได้ แค่นี้เองครับ
ตัวอย่าง เครื่องพิมพ Epson LQ 2180i แทนที่จะใช้ Driver ของรุ่นนี้แต่เปลี่ยนไปใช้ Driver รุ่น
LQ-1170 ESC/P 2 แทน หวังว่า Blog นี้จะช่วยแก้ปัญหาให้หลาย ๆ ท่านได้ครับ
การพิมพ์ Label จาก Crystal report โดยใช้กระดาษต่อเนื่องที่มีขนาดเล็กนั้นอาจมีปัญหาว่า
สร้าง Form กระดาษให้ตรงตามจริงแล้ว ตอนสั่งพิมพ์ไม่สามารถเลือกฟอร์มกระดาษที่กำหนดขึ้นได้
กรณีที่เคยพบคือ ใช้เครื่องพิมพ์ EPSON LQ 2180i พิมพ์ Label แปะซองจดหมายถึงลูกค้า แต่ขนาดของ
Label มีขนาด Width : 11 cm และ Height : 3.5 cm ซึ่งเครื่องขนาดของฟอร์มกระดาษเล็กกว่าขนาดที่
เล็กที่สุดที่เครื่องพิมพ์รองรับทำให้เครื่อง Printer ไม่สามารถ Detect เจอ size กระดาษนั้นได้
จึงได้โทรไปสอบถามทาง Epson ถึงวิธีการแก้ไข จึงได้ทราบวิธีที่ง่ายมาก คือเพียงแต่เปลี่ยนไปใช้
Driver ของเครื่องพิมพ์รุ่นที่เก่ากว่า ก็จะทำให้สามารถสั่งพิมพ์ลงใน Form ที่มี ขนาดเล็กได้ แค่นี้เองครับ
ตัวอย่าง เครื่องพิมพ Epson LQ 2180i แทนที่จะใช้ Driver ของรุ่นนี้แต่เปลี่ยนไปใช้ Driver รุ่น
LQ-1170 ESC/P 2 แทน หวังว่า Blog นี้จะช่วยแก้ปัญหาให้หลาย ๆ ท่านได้ครับ
สมัครสมาชิก:
บทความ (Atom)