This is my table :
I want is to display messageBySession, imageBySession and videoBySession in Columns and UserDimension with dateDimension in Row. Is this possible ?
Edit
Here is my attempt at the query :
SELECT
{
[Measures].[MessageBySession]
,[Measures].[ImageBySession]
,[Measures].[VideoBySession]
} ON COLUMNS
,Hierarchize(CrossJoin([DateDimension].Children,[UserDimension].Children)) ON ROWS
FROM [SessionFacts];
I just need to Join DateDimension with UserDimension. i hope it can help someone.
i found the query :
select {
[Measures].[MessageBySession],
[Measures].[ImageBySession],
[Measures].[VideoBySession]
} ON COLUMNS,
Hierarchize(
CrossJoin(
[DateDimension].children,
[UserDimension].children
)
)
ON ROWS
from
[SessionFacts]
I just need to Join DateDimension with UserDimension. i hope it can help someone.
Related
In the example below I want to find sum of each group. Can someone correct my MDX query to get the desired result for GroupCount Column.
with member [GroupCount] as
aggregate([Department].[Department ID].currentmember.parent,
[Measures].[Pay Frequency])
select {[Department].[Group Name].[all].children*
[Department].[Department ID].[all].children
} on rows,
{[Measures].[Pay Frequency],[GroupCount]} on columns
from test
The result I am getting from the above query is:
However I need the output as :
Is it like this?
with member [GroupCount] as
(
[Department].[Group Name].CURRENTMEMBER,
[Department].[Department ID].[All],
[Measures].[Pay Frequency]
)
select {[Department].[Group Name].[all].children*
[Department].[Department ID].[all].children
} on rows,
{[Measures].[Pay Frequency],[GroupCount]} on columns
from test;
I'm trying to filter my MDX query of can someone help me on how this can be done.
My code
Select
[Measures].[Net_Cost] on 0,
[State].[City] on 1
FROM
[SALES]
WHERE
([Date].[Date.AYearly].[2017]),([Date].[Date.AMonthly].[1] : [Date].[Date.AMonthly].[12])
and it throws an error.
I want to accomplish the following:
Where
year = 2017 and month is between 1 and current month.
How can this be done.
Thanks in advance
Maybe try one filter in a subselect and the other in the outer query:
SELECT
[Measures].[Net_Cost] on 0,
[State].[City] on 1
FROM
(
SELECT
[Date].[Date.AYearly].[2017] ON 0
FROM [SALES]
)
WHERE
([Date].[Date.AMonthly].[1] : [Date].[Date.AMonthly].[12])
;
Thanks #whythe1 i did something like this
SELECT
NON EMPTY
[Date].[Date.AYearly].[Year].[2017]:
[Date].[Date.AYearly].[Year].[2017].PrevMember ON 0,
NON EMPTY
CROSSJOIN
(
CROSSJOIN(
{[Measures].[Net_Prod_Cost]},
{[Territory].[Sales_Territory_Branch_Number].Members,
[Territory].[Sales_Territory_Branch].Members}
),
{[Products].[Products.SBM].[RYAN WEST]}
) ON ROWS
FROM [SALES]
WHERE
(
({[Date].[Date.AMonthly].[Month].[1] :
[Date].[Date.AMonthly].[Month].[11]})
)}
and it worked.
Thanks your answer gave me an idea.
I want to join the following tables (records, tip). Goal is that the missing WAR rows (dependend on the ID) will be added. For example you see that WAR = 2 is missing for ID = 80.
Note: WAR is always smaller or equal with the value of TIP. The value of Value should be NULL in the added rows. The table in the bottom is the goal.
I am not sure how to solve this problem. But a condition that results of this is records."TIP" >= tip."TIP".
I use HANA as database.
Thank you in advance. Best regards.
This is how it works (sorry all these TIPs are a little bit confusing):
SELECT a."ID", b."TiP" "WAR", c."VAL" FROM (
SELECT DISTINCT "ID", MAX("TIP") "max" FROM records t
GROUP BY "ID"
) a
INNER JOIN tip b ON 1=1
LEFT JOIN T0 c ON a."ID" = c."ID" AND b."TiP" = c."WAR"
WHERE b."TiP" <= a."max"
ORDER BY a."ID", b."TiP"
I'm trying to write an MDX query with the equivalent SQL:
SELECT m.ID, m.CID, m.Orders
FROM dbo.Measures as m
WHERE SUBSTRING(m.CID, 1, 4) <> 'PID_'
Essentially, exclude all rows where CID begins with 'PID_'
This is what I have in MDX so far:
SELECT
{
[Measures].[ID] AS ID,
[Measures].[Orders] AS NumberOfOrders,
}
ON COLUMNS,
{
[Channel].[Channel Account ID].[Channel Account ID].Members
* [Channel].[Channel].[Channel].Members // exclude accounts starting with 'PID_'
}
I've tried EXCEPT and - and WHERE clauses, but none seem to work.
Any help is appreciated!
I found the answer with the links xQbert provided.
This was the answer:
ON COLUMNS,
{
FILTER([Channel].[Channel Account ID].[Channel Account ID].Members,
LEFT([Channel].[Channel Account].Properties("Channel Account ID"), 4)
<> "PID_")
* [Channel].[Channel].[Channel].Members
}
I need some help building an Query.
I have a table "Orders" with 3 fields (IDorder, IDcostumer and amount) and i'm trying to create an List where i add one row for each costumer with the total of amount.
Can someone help me building this query?
Try the following:
SELECT IDCustomer, SUM(amount)
FROM Orders
GROUP BY IDCustomer
SELECT sum(amount), IDcostumer FROM Orders GROUP BY IDcostumer
Thanks for the answer. With your query i've tried to joined another table and converted it to LINQ with linqer. The final code was:
from c in contexto.Costumers
join s in contexto.Sales on c.IDcostumer equals s.IDCostumer
group new {c, s} by new {
c.IDcostumer,
c.name
} into g
select new {
IDcostumer = (Int32?)g.Key.IDcostumer,
g.Key.name,
total = (Decimal?)g.Sum(p => p.s.total)
}
Unfortunately i haven't understand yet the meaning of group and how it works.
I'll read a few articles to try to understand it.
Thanks ;)