Showing posts with label query. Show all posts
Showing posts with label query. Show all posts

Friday, January 20, 2012

install Adventure Works SQL DW

How to install Adventure Works SQL DW and Analysis Services 2005/2008 sample database and project  

Below is the link for that contains the Adventure Works DB file and the process to install the DB, that is the sample database to learn the MDX queries

Tutorial
How to Install SSAS database

Thursday, September 15, 2011

Add complex conditions in AOT Query in Dynamics X++

Sometimes you need to add complex conditions in your query to acheive the requirement. Below example will help you to achieve this


So i want to add these condition on query
BudgetSourceTracking.Category == BudgetControlCategory::Original || ( BudgetSourceTracking.Category == BudgetControlCategory::CarryForwardBudget && BudgetSourceTracking.Status == BudgetSourceTrackingStatus::Confirmed) || ( BudgetSourceTracking.Category != BudgetControlCategory::Original && BudgetSourceTracking.Category != includeCarryForward)
----
rangeCrtiteria is any string data type, you notice that i have added the condition of Status field too, but its alos working in this case
 rangeCriteria = strfmt('((((%1.%2 == %3) || ((%1.%2 == %4) && %7)) && (%1.%5 == %6)) || ((%1.%2 != %3) && (%1.%2 != %4)))',
                                    query.dataSourceTable(tablenum(BudgetSourceTracking)).name(),
                                    fieldstr(BudgetSourceTracking,Category),
                                    any2int(BudgetControlCategory::Original),
                                    any2int(BudgetControlCategory::CarryForwardBudget),
                                    fieldstr(BudgetSourceTracking,Status),
                                    any2int(BudgetSourceTrackingStatus::Confirmed),
                                    any2int(includeCarryForward));
       
query.dataSourceTable(tablenum(BudgetSourceTracking), 1).addRange(fieldnum(BudgetSourceTracking, Category)).value(rangeCriteria);
       
queryRun = new QueryRun(query);

How to add date range in query at run time in Dynamics AX, X++

It want to add the date range on the query at run time. how can i achieve this.


Ans.


query.dataSourceTable(tablenum(BudgetSourceTracking), 1).addRange(fieldnum(BudgetSourceTracking, TrackingDate)).value(queryRange( fiscalPeriodStartDate, fiscalPeriodEndDate));