Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 views
in Technique[技术] by (71.8m points)

pentaho - How to extract month, year and date from Date level in MDX

It is my first time working with MDX in JPivot, I have a Date level (Format: YYYY-MM-dd) and I have to do some queries based on the year or month of this date. I did not find a way to extract this separately.

This is my query :

select {[Person].[job].Members} ON COLUMNS, {[WorkDate].[Date].Members} ON ROWS from [Work]

Is there a way to do it?

Thank you in advance!

question from:https://stackoverflow.com/questions/65910762/how-to-extract-month-year-and-date-from-date-level-in-mdx

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If the [Workdate] hierarchy has Year and Month levels, you can access those by using

[Workdate].CurrentMember.Parent.Parent.Name

(assuming Year is the grand-parent level of Date)

or

Ancestor( [Workdate].CurrentMember, [Workdate].[Year]).Name

If you don't have a Year/Month/Date hierarchy then you'll need to break the date string into bits using [Workdate].CurrentMember.Name and string functions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...