SSAS PowerPivot MDX Problems w/ Measures Format_string - format

I am investigating a problem about Calculated Measures format issue from an OLAP Cube.
I get these numbers :
I am using this mdx request:
WITH MEMBER [Measures].[Ristournable Format] AS [Measures].[Ristournable], FORMAT_STRING = 'Currency'
SELECT
NON EMPTY { [Measures].[Ristournable Format] } ON COLUMNS,
NON EMPTY { ([Affaire].[Affaire].[Affaire].ALLMEMBERS ) } ON ROWS
FROM [CUBE]
But it doesn't work. I think the problem comes from the "." instand of "," for the numbers so my MDX request is using it as String. That's why I tried to force the numeric conversion with the first sentence "WITH MEMBER ...". Unfortunately this doesn't work either.
Could you please help me to solve it?

Have you tried FORMAT_STRING='$##0.00' or some other explicit way of telling MDX exactly what you want, rather than just passing 'Currency'?

Related

Alternative to PowerBI FILTER() function in Tableau calculated field

I am trying to recreate the following calculation from PowerBI in Tableau but I am not sure how to achieve what FILTER() function does.
(CALCULATE(SUM(Data[Amount]),FILTER(Data,Data[Paid]="True"))/SUM(Data[Amount]) +
CALCULATE(COUNT(Data[Document ID]),FILTER(Data,Data[Paid]="True"))/COUNT(Data[Document ID]))/2
My assumption was to use IF or CASE but then I couldn't figure out how to divide by number of all documents, regardless of their payment status.
I suppose you need the following:
SUM(IF [paid] = "True" then [Amount] end)/SUM([Amount])
+
COUNT(IF [paid] = "True" then [Document ID] end)/COUNT([Document ID])/2
The filter is specified using the if statement.

Power BI DAX measure: Count occurences of a value in a column considering the filter context of the visual

I want to count the occurrences of values in a column. In my case the value I want to count is TRUE().
Lets say my table is called Table and has two columns:
boolean value
TRUE() A
FALSE() B
TRUE() A
TRUE() B
All solutions I found so far are like this:
count_true = COUNTROWS(FILTER(Table, Table[boolean] = TRUE()))
The problem is that I still want the visual (card), that displays the measure, to consider the filters (coming from the slicers) to reduce the table. So if I have a slicer that is set to value = A, the card with the count_true measure should show 2 and not 3.
As far as I understand the FILTER function always overwrites the visuals filter context.
To further explain my intent: At an earlier point the TRUE/FALSE column had the values 1/0 and I could achieve my goal by just using the SUM function that does not specify a filter context and just acts within the visuals filter context.
I think the DAX you gave should work as long as it's a measure, not a calculated column. (Calculated columns cannot read filter context from the report.)
When evaluating the measure,
count_true = COUNTROWS ( FILTER ( Table, Table[boolean] = TRUE() ) )
the first argument inside FILTER is not necessarily the full table but that table already filtered by the local filter context (including report/page/visual filters along with slicer selections and local context from e.g. rows/column a matrix visual).
So if you select Value = "A" via slicer, then the table in FILTER is already filtered to only include "A" values.
I do not know for sure if this will fix your problem but it is more efficient dax in my opinion:
count_true = CALCULATE(COUNTROWS(Table), Table[boolean])
If you still have the issue after changing your measure to use this format, you may have an underlying issue with the model. There is also the function KEEPFILTERS that may apply here but I think using KEEPFILTERS is overcomplicating your case.

MDX: add dimension in filter but also show in rows

I have a simple MDX query that filters data to one of two Status values:
SELECT
NON EMPTY
{ [confidentialstring].Members }
ON COLUMNS,
NON EMPTY
{ [APMWORDER].[LEVEL01].Members *
[APMSTDOPR].[LEVEL01].Members *
[AWOUSTAT].[LEVEL01].Members *
[ANOTIFCTN].[LEVEL01].Members
}
ON ROWS
FROM [APM_CP002/APM_CP002_QX006]
WHERE { ( [AWOUSTAT].[E0001] ), ( [AWOUSTAT].[E0002] ) }
But I also need [AWOUSTAT] in my table, to see which status value is actually applicable.
However MDX throws an error if I add it: 'You may not use the same dimension on different axes'. I understand this in principle but not in this application ('filter' is not an axis to me...)
How can I resolve this, without having to create two queries?
Thanx!
Since you cannot have the same dimension on rows and in where clause, and you want to see [AWOUSTAT].[E0001]] , [AWOUSTAT].[E0002] , in your table, I think you could try something like this to start:
SELECT
NON EMPTY
{ [confidentialstring].Members }
ON COLUMNS,
NON EMPTY
{ ( [AWOUSTAT].[E0001]] ), ( [AWOUSTAT].[E0002] ) }
ON ROWS
FROM [APM_CP002/APM_CP002_QX006]
A common technique is to replace the WHERE clause with a FROM clause.
Sample using adventure works:
SELECT
NON EMPTY
{[Measures].[Order Count]} ON COLUMNS
,NON EMPTY
{[Date].[Day of Month].[Day of Month].ALLMEMBERS}
ON ROWS
FROM
(
SELECT
{[Date].[Fiscal Year].&[2011]} ON COLUMNS
FROM [Adventure Works]
)
In the above example, it is equivalent to having a WHERE clause of the Fiscal Year = 2011.
You can see a similar output, whenever you use the SSMS Cube Browser to build queries.
It may look strange to replace WHERE with FROM, BUT, in the in most cases with the Cube, it does provide the required output.

DAX Filter function parameter from a measure

I'm trying to set up a custom filter using DAX in Power BI.
The idea is to use a parameter/value extracted from a Slicer.
So far, I was able to get the selected value from the Slicer, but I was not able to use it in a filter.
The filter expression works perfectly when I manually type the parameter "value", I mean:
FILTER(BI_PRD_MAPA_TRD, BI_PRD_MAPA_TRD[ORIG_GRUPO]="5DSL" || BI_PRD_MAPA_TRD[DEST_GRUPO]="5DSL")
Works just fine, but:
FILTER(BI_PRD_MAPA_TRD, BI_PRD_MAPA_TRD[ORIG_GRUPO]=[Measure] || BI_PRD_MAPA_TRD[DEST_GRUPO]=[Measure])
doesn't work.
The measure is working fine, as I created a "dummy" card to test it.
The measure itself is calculated by a DAX SELECTEDVALUE function:
Measure = SELECTEDVALUE(Tabela[GRUPO], "TODOS")
Can someone help me at this topic?
Get the measure value in a VAR in this DAX and use inside to it, as below.
VAR _SelectedValue = [Measure]
RETURN
FILTER(BI_PRD_MAPA_TRD, BI_PRD_MAPA_TRD[ORIG_GRUPO]=_SelectedValue || BI_PRD_MAPA_TRD[DEST_GRUPO]=_SelectedValue )
I believe the selection is single select not multiple.

How can I use the "WHERE" clause in MDX or its equivalent?

im' working with analysis services. I need to perform a calculation and for this i use kpi. In the field "value expression" from KPI i establishid the calculation with an expression MDX. Works fine but i don't know how put the clause "WHERE" in the query o how use it
(([Measures].[Recuento Factonlymatriculacion],[Dimmatriculacion].[Nivel].&[Universitario])*100)/([Measures].[Recuento Factsolicitud],[Dimplan].[Nivel].&[Universitario]))
WHERE
([Measures].[Recuento Factsolicitud],[Dimaniosolicitud].[Anio]) IS ([Measures].[Recuento Factmatriculacion],[Dimmatriculacion].[Anio])
I don't think you need WHERE. Just form a two part tuple, with Anio as the second part:
(
DIVIDE(
([Measures].[Recuento Factonlymatriculacion],[Dimmatriculacion].[Nivel].&[Universitario] * 100),
[Measures].[Recuento Factsolicitud],[Dimplan].[Nivel].&[Universitario]
)
, [Measures].[Recuento Factmatriculacion],[Dimmatriculacion].[Anio]
)
But there looks to be an issue as Anio is part of Measures so I don't understand how your original logic will return anything other than blank?

Resources