How to use MDX query to specify date range - sql

I'm recently trying out using MDX query in Power BI to query information directly from SAP Business warehouse cube. I encountered an error message that I can't figure out how to solve. The error message is: "SAP Business Warehouse: Specify a value for variable Day Interval"
In the report, choosing date range is mandatory. If I click through using Power BI to SAP BW connector, one of the steps is like the screenshot below:
The day is in the Cube called [0CALDAY] and is specified using [0CALDAY].[20101107]
However if I use MDX to query similar data using the code below
select {[Measures].[00O2THVIBBMJV8JIFLLW439K8]} on columns
from [0PT_MP01/Y_PT_TM_Q001_BOBJ]
where {[0CALDAY].[20101101]: [0CALDAY].[20101110]}
and click OK, I will receive the message says: "SAP Business Warehouse: Specify a value for variable Day Interval". My understanding of this is the way I'm choosing day interval is not recognized?
I've also tried to use & in front of [20101101] to make something like this: [0CALDAY].&[20101101] (according to some of the introduction online), then I receive syntax error message.
Is there anything I can do with the query language? Do I need to convert the number into date type? I'm really new to MDX and Cube, any suggestions will be really appreciated.
Thanks

You are required to add an SAP Variable at the end of the query.
To do this you can add an SAP Variable the following way:
SAP VARIABLES [<technical name of variable>] INCLUDING <value for variable>
Your query would end up looking like this:
select
{
[Measures].[00O2THVIBBMJV8JIFLLW439K8]
} on columns
from
[0PT_MP01/Y_PT_TM_Q001_BOBJ]
sap variables
[0CALDAY] including "20101101":"20101110"
Please find more information here:
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=356124639
https://blogs.sap.com/2005/06/08/quick-help-in-creating-mdx-statement/

I would give an example to help explain the usage of mandatory SAP variables:
SELECT { [Measures].[measure1_name], [Measures].[measure2_name] } ON COLUMNS, NON EMPTY { [dimension1_name].[LEVEL01].MEMBERS, [dimension2_name].[LEVEL01].MEMBERS } ON ROWS FROM [BExQuery_name] SAP VARIABLES [!V000001] INCLUDING [dimension1_name].[80000000103] [!V000004] INCLUDING [0CALDAY].[20130101]:[0CALDAY].[20130104]
!V000001 and !V000004 are BEx variables.
The 80000000103 is a sample value for "dimension1_name". The 20130101 and 20130104 are sample range for 0CALDAY.

Related

Heat map visualization issue Microstrategy VI

I am creating a Dashboard using as a visualization a heat map. Everything was OK until I changed the parameters of my metric, the chart disappeared and I've got this message: 'Filter excludes all data'
The only modification that I've done is to set the Include Distinct Elements to true within the Count Parameter option of the metric.
What could be happening?. Do I need to set another parameter to get the count of distinct elements that I need?
Regards.
surely the metric is level with some attribute that is not inside the visualization, if the filter has date for example, include it in the visualization.
"Filter Excludes All data" is a default warning message that you will get in MicroStrategy when a reports/visuals/dashboards does not return any data.
https://community.microstrategy.com/s/article/KB47557-How-to-Properly-Suppress-the-Message-Filter-excludes-all?r=1&Component.reportDeprecationUsages=1&Headline.getInitData=1&ArticleView.getArticleHeaderDetail=1&Quarterback.validateRoute=1&RecordGvp.getRecord=1&ArticleRichContent.getArticleAuthor=1&ArticleTopicList.getTopics=1&ArticleRichContent.hasArticleAccess=1&ForceCommunityFeed.getModel=1&ArticleRichContent.getTopicsAssigned=1
There are n number of reasons for a report which cannot return data, please check the following steps to debug the issue,
As per your first image it shows a date range as filter, after you have changed to "Include only distinct" this date range might get affected so please put the objects in grid and apply the date filter and check whether it returns the correct data.
If it returns, check whether all the metrics returns a value.
Check whether candidateID, date and people attributes/metrics are properly related.
These steps will show, where the problem is, still if you could not figure it out export the dashboard and share it with MicroStrategy Tech Support team for debugging.
Hope it helps.

How do can I return a summation of the results of MB51 instead of the row-by-row transactions?

I am using SAP for Windows (SAP NetWeaver; 730 Final Release, Version 7300.3.15.1085) and I need to find a faster way to do part of my routine. I use the form MB51 along with some criteria to find all transactions I need. Then, I select the Quantity in UnE column and hit the sigma (Add Up Values) symbol at the top. This gives me the sum total of all rows at the bottom.
The goal is to simplify this process. I want to be able to add in the material, the plant, the reference, and the document header texts and just return the sum of all rows. I literally only need the final sum and nothing else. Does anyone know of a form in SAP that can help me do this? Or does anyone know of a way to customize MB51 so that I achieve my desired output?
In addition to a Dirk's proposal to use SAP Query, you can consider creating SAP transaction variant and running it in a background mode.
This allows executing a transaction with the specified parameters (including summation) periodically and sending results to email.
It looks like you lack development permissions on the system, so this can be simplest way for acquiring a MB51 sum. Besides permissions, your task also requires knowledge of MB51 tables and their relations.
Just create a layout variant and create a variant for the selection screen with the layout variant. You can also hide unused fields with the selection variant.

multiple Filters in Jasper Report

I have Created a Student Information Report using Jasper report (SQL database). I need to filter the report using different parameters. e.g
Branch Wise
Gender Wise
Class Wise
Section Wise and some more
I'm using Java Swing as a front end application.
My question is for each filter i have to write separate query?? or is there a way in jasper to manage different filter for example.
You can manage your query based on the parameter you got using a different expression which is $P!{}.
Follow below steps to achieve your needs,
Create a parameter, say $P{BranchWise}.
In the expression of that parameter, write something like
$P{Branch} != null ? "and branch = '"+$P{Branch}+"'" : ""
Likewise create parameter for different filters.
Now use these parameters in your query as below
select * from table1 where 1=1 $P!{BranchWise} $P!{GenderWise} $P!{ClassWise} ....
Hope this should solve your problem.

Quickbooks DB Microsoft Query SQL string edit to render all data from a table

I have a SQL string that is from a report in Quickbooks that I am running through MS Query over an ODBC connection. I have successfully made a few minor edits to it. This report is a Profit and Loss statement showing general ledger accounts with dollar values for each class (identifier for those dollar amounts, basically a company code) where the accounts are the rows and the classes are the columns. I would like to pull ALL data for the class table, however I only have the SQL language screen. So my question is either:
What do I add to this SQL language to force the query to show all classes (categories) from the table regardless of whether there is account data (dollars) within them?
OR Is there some way to show the tables so that I can edit them in this report where I only have the SQL string? Then what kind of function would I need to use to set this parameter.
This is the SQL text:
sp_report ProfitAndLossByClass show Amount_Title, Text, Label, Amount parameters DateMacro = 'LastMonth', SummarizeColumnsBy = 'Class'
Any thoughts on how to either open the tables from this report or how I can add to my SQL string to allow the report to show all classes names from the table would be greatly appreciated.
Thanks,
Amy
This query is calling a Stored Procedure called sp_report and passing some parameters to it. I don't have QuickBooks, so there is no way I can tell you what sp_report does - maybe you can find out?
I'd check your Quickbook licence, though. Software suppliers often have clauses forbidding reverse engineering, which is what you're doing.

Building SSRS time series report from SQL datetime column

I need to create a SSRS report where the user specifies the start and end date (e.g. March 2012 to July 2012) and the result is a report with the following headings:
User Department Product Mar-12 Apr-12 May-12 Jun-12 Jul-12
The dates are stored in a datetime column (e.g.2012-06-11 14:48:04.787) in my SQL table which I'm using to build the time-series report.
Do I need to convert/transpose my SQL table first? Or should I be processing this in SSRS?
Your advice is much appreciated!
Based on your question it appears all your dates are in a single datetime column and your trying to display them, formatted as a month, in a single report with the report columns grouped and renamed based on the month. This is a pivot and I don't think you can do that within SSRS. The dataset will already need to be pivoted by the time SSRS gets it.
So, to me this sounds like something you'll have to do both pre and post SSRS. I did a similar report using days of the month. You can see the winning answer here. as opposed to months of the year.
Thinking through your logice, I think you'll probably have to build the query with the pivot and then send to SSRS. On the SSRS side you need 12 columns for all 12 months and then put some logic to hide the ones that don't get data. Your original pivot will need to be smart enough to pass the empty months so SSRS doesn't error out. The end result will appear the same but needs a lot of pre-thought and design effort up front.
You do the processing using SSRS - you would design it in the GUI editor(BIDS ) , and you can customize things using the VBasic code also(i.e, dates and logic)
Looks like you need an intro, I really recommend this video