cancel
Showing results for 
Search instead for 
Did you mean: 

Get current date from database

Former Member
0 Kudos

I have 2 queries created

Query 1

Year, Quarter, Customer, Month, Est Sales, Actual Sales

Query 2

Current Month

In the report, I will compare the Month (Query 1) with Current Month(Query 2).

If Month >= Current Month, then Est Sales will show up

else Actual Sales.

Now what I did is to define a variable as measure type

V_Current_Month = Max([Current Month])

The formula for each quarter should be:

=[Est Sales] where ([Month]>=[V_Current_Month]) + [Act Sales] where ([Month]<[V_Current_Month])

But it didn't work for me.

then I output this variable to report, it's exactlly 3, If I hard code the variable "V_Current_Month" to 3, it works,

So what's the difference between the variable I defined and the hard-coded one?

Edited by: GodBlessMe on Mar 22, 2010 6:05 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Did you check the values for query2?

I think query2 has the current month no only thats why your variable is not working.

Can you please check the query?

Former Member
0 Kudos

The query is fine, I just output the result to report, it's just what I want, when I wrote a formula to compare current month from this query to a fixed value 03, and get true always.

Former Member
0 Kudos

But it didn't work for me.

What didn't work? Did you get an error message? Or just not the results you expected? Have you checked the objects to make sure you are comparing dates to dates and numbers to numbers?

Also, why do you need two queries? Are the date dimensions merged?

Thanks

Former Member
0 Kudos
=[Est Sales] where ([Month]>=[V_Current_Month]) + [Act Sales] where ([Month]<[V_Current_Month])

I am getting all [Est Sales], because the [V_Current_Month] was set to zero in speed of it's 3. so it didn't work for me.

Yes, I can make sure the [Month] and [V_Current_Month] are numbers

We are using fiscal date, for example the day May 2 may belong to April. so we have to get the current stuff from datebase level.