DAX - Querying: How to reinforce a filter in order to calculate a year to date

Dear community,
I am pulling my hair off due to an issue I am having with the creation of a DAX query (supposed to feed an SSRS report).
The topic is P&L related, I need to compute the revenue based on specific cost elements, that same query must return additional columns that represent YTD, Forecast,... etc ( a couple of typical aggregations).
First of all here is the query I currently simplified to explain my issue:
EVALUATE
CALCULATETABLE(
SUMMARIZE(
GENERATE(
VALUES(AccountingPeriod[RealAccountingPeriod]),
FactFInancialTransaction
AccountingPeriod[Code],
CostElement[Code],
CostElement[Group],
"Revenue", [Revenue],
"GroupRevenue",
CALCULATE(
[Revenue],
all(CostElement[Code])
FILTER(
VALUES(CostElement[Code]),
CostElement[Code] = "RSFOR" ||
CostElement[Code] = "RSTHI" ||
CostElement[Code] = "RSOTH"
FILTER(
VALUES(CostElement[Group]),
CostElement[Group] = "RGOVE"
FILTER(
ALL(AccountingPeriod),
AccountingPeriod[Code] = 201402
FILTER(
VALUES(OperationalUnit[OperationalUnitNumber]),
VALUES(OperationalUnit[OperationalUnitNumber]) = "052"
The Revenue is simply a SUM of an amount column in FactFinancialTransactions.
What I am unable to do is compute GroupRevenue where I simply would like to sum the revenues for the elements. Does anybody have an idea on the calculate statement that will help me achieve this?
 I tried doing something like:
CALCULATE(
[Revenue], all(FactFinancialTransactions),
all(CostElement[Code]), Values(CostElement[Group]), Values(AccountingPeriod[code]) Values(OperationalUnit[OperationalUnitNumber]) )
This does not work at all, it looks like the VALUES(OperationalUnit[OperationalUnitNumber]) context is not reinforced, the value I get in return is actually the one summing ALL operational units.
PS: I have to keep the filter on OperationalUnit as is because it will actually be a pathcontains statement that can pass multiple values
Thanks so much for any help
Mils.

I am not entirely sure about your requirements and your data model.
However, I would start using ADDCOLUMNS instead of SUMMARIZE to add columns to the group you need.
EVALUATE
CALCULATETABLE (
    ADDCOLUMNS (
        SUMMARIZE (
            GENERATE (
                VALUES ( AccountingPeriod[RealAccountingPeriod] ),
                FactFInancialTransaction
            AccountingPeriod[Code],
            CostElement[Code],
            CostElement[Group]
        "Revenue", [Revenue],
        "GroupRevenue", CALCULATE ( [Revenue], ALL ( CostElement[Code] ) )
    FILTER (
        VALUES ( CostElement[Code] ),
        CostElement[Code] = "RSFOR"
            || CostElement[Code] = "RSTHI"
            || CostElement[Code] = "RSOTH"
    FILTER (
        VALUES ( CostElement[Group] ),
        CostElement[Group] = "RGOVE"
    FILTER (
        ALL ( AccountingPeriod ),
        AccountingPeriod[Code] = 201402
    FILTER (
        VALUES ( OperationalUnit[OperationalUnitNumber] ),
        VALUES ( OperationalUnit[OperationalUnitNumber] ) = "052"
Marco Russo (Blog,
Twitter,
LinkedIn) - sqlbi.com:
Articles, Videos,
Tools, Consultancy,
Training
Format with DAX Formatter and design with
DAX Patterns. Learn
Power Pivot and SSAS Tabular.

Similar Messages

  • How to calculate Prior Year To Date in SSRS

    Hi,
    I've been developing reports in Crystal for a while. The new ERP software we have just purchased uses SSRS for all of their reports. I just started converting the crystal reports to SSRS. I can't seem to find an easy way to do a calculation for Prior Year
    to Date or Prior Year Month to Date in SSRS. Can somebody help me?
    Thanks,
    Cindy

    Your best bet would be to use a calendar table in the TSQL queries. I wrote an article on them here: http://social.technet.microsoft.com/wiki/contents/articles/29260.tsql-calendar-functions-and-tables.aspx
    Alternatively you can use a formula like:
    =DateValue(DATEADD(DateInterval.Day,1-DATEPART(DateInterval.DayOfYear,NOW()),Now()))
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • How do i get my subscription calendar load a full year of data instead of only 3 months?

    I have loaded subscription calendars into my iCal (such has US Holidays, Jewish Holidays).  However, I recently noticed that only the next 3 months of events are loaded into to my iCal.  I would like to have at least the next 12 months if not more.  Is there an option that I am not finding that will allow me to make this change?

    Betsy,
    The publisher of the calendar may only release items three months in advance.
    Can you provide the source of the calendar?

  • How to handle 3 different fact tables and measures within a DAX query?

    I am writing a DAX query in DAX studio in Excel against a tabular model that has 4 different Fact tables, but they share the same dimensions. (There's some long story I can't get into here, but unfortunately this is the structure) I want to
    include measures from the 4 fact tables, summarize by the dimensions in a single query output that can be used for a pivot table.  So far I have something like this:
     EVALUATE
    FILTER
        SUMMARIZE
            FactTable1,
            DimensionTable1[Value],        DimensionTable2[Value],
            DimensionTable3[Value],
            Dimensiontable4[Value],
            'dimDateTime'[Month PST],
            DimDateTIme[FiscalYear PST],
            "Measure Score",
            FactTable1[Measure 1],
            "Measure Score 2",
            FactTable1[Measure 2],
        ,Company[CompanyName]="Company ABC" 
    What I want to do is summarize the 3 fact tables by the same dimensions, but I am not sure how to do that within a DAX query.  I am getting an error if I try to include another table statement in the original SUMMARIZE function, even though the FACTS
    do share the same dimension.  Is there an easy way to do this?

    You can use ADDCOLUMNS to add the data from other tables, but you need to use within the SUMMARIZE the fact table that determines the cardinality of the output. If you are not sure (e.g. you project cost and revenues from two fact tables by month and there
    could me months with cost and no revenues, but also months with revenues and no costs), then you should use CROSSJOIN and then FILTER.
    You query might be written as (please note CALCULATETABLE instead of FILTER to improve performance):
    EVALUATE
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE (
                FactTable1,
                DimensionTable1[Value],
                DimensionTable2[Value],
                DimensionTable3[Value],
                Dimensiontable4[Value],
                'dimDateTime'[Month PST],
                DimDateTIme[FiscalYear PST]
            "Measure Score", FactTable1[Measure 1],
            "Measure Score 2", FactTable1[Measure 2]
        Company[CompanyName] = "Company ABC"
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • How to retrieve dynamic filter value submitted from control query to .....

    How to retrieve dynamic filter value submitted from control query to broadcast query.....
    I'm trying to change the hierarchy version determined by a userexit variable in the broadcast query.
    The Hierarchy Version should be dependent on the input filter delivered by the bursting query.
    But how do I catch the dynamic filter value which has been submitted by the bursting query,
    with other words:  where does the bursting query store it's out put while sequentially starting the broadcast query value by value?
    BTW: the filter value from the bursting query appears under "dynamic filter values" in the information of the broadcast query...
    Any thoughts are welcome!
    Edited by: Heinrich Krupp on Jun 24, 2009 1:25 PM

    Further information,
    Report is used via webi only, not Xcelsius or Dashboard.
    Report is consuming BI Web Services.
    Although we can pass in prompt values to BI Services, I couldn't find if we could pass a variable or dimension object into this field. Anyone knows?

  • DAX query to calculate distinct count respect to a column after a Filter function - SSAS 2012 Tabular

    Hi,
    I'm trying to build the dax query to determine the distinct count for a column returned by the application of a Filter function.
    evaluate(
    row("counter",
    countrows(
    filter(order_summary,
    year(order_summary[change_date]) = 2013) )
    I need to count the distinct values for an id returned by the Filter function.
    Any helps, please? Thanks

    Hi pscorca,
    According to your description, you want to calculate the distinct values for records where change_date is 2013. Right?
    In this scenario, we can use the DISTINCT() function within COUNTROWS(). Please try the expression below:
    =calculate(
    countrows(distinct(order_summary[column])),
    Filter('order_summary', year(order_summary[change_date])=2013)
    Reference:
    Distinct Count Measure in PowerPivot using DAX
    Related Distinct Count
    Best Regards,
    Simon Hou
    TechNet Community Support

  • How to create a WMI filter in order to apply to machines that have Skype already installed with deploying a newer version of Skype

    Hi there,
    I was wondering whether anybody could tell me how to create a WMI filter in order to apply to machines that have Skype already installed with deploying a newer version of Skype.
    Your help would be much appreciated.
    Many thanks,
    Timbuctoo

    Hi,
    To create a WMI filter
    1.In the Group Policy Management Console (GPMC) console tree, right-click
    WMI Filters in the forest and domain in which you want to create a WMI filter.
    2.Click
    New .
    3.In the
    New WMI Filter dialog box, type a name for the new WMI Filter in the
    Name box, and type a description of the filter in the Description box.
    4.Click
    Add .
    5.In the
    WMI Query dialog box, either leave the default namespace (root\CIMv2) or enter another namespace by doing one of the following:
    ◦ In the
    Namespace box, type the name of the namespace that you want to use for the WMI query.
    ◦ Click
    Browse , select a namespace from the list, and then click
    OK .
    6.Type a WMI query in the
    Query box, and then click OK .
    7.To add more queries, repeat Steps 4 through 6 to add each query.
    8.After adding all queries, click
    Save .
    In the Query box, type the following WMI query:
    Select * from Win32_Product where Name LIKE “%Skype%”
    Best Regards,
    Erin

  • Reading the DAX query plan of a trace against a query on a Tabular model

    Hi,
    I'm monitoring a Tabular model queried by an Excel workbook. Inside SQL Profiler I've choosen as events the VertiPaq SE Query End, the Query End and the DAX Query Plan. But this last event isn't more readable.
    How can I read the info collected in the DAX Query Plan in a simple manner?
    Thanks

    It is fairly complex to read the DAX Query Plan. I don't think there are currently tools that make it easier to read. (Watch the DAX Studio project on codeplex as they may include tools for this in the future.) I would recommend you review the Tabular
    Performance Guide which has a good explanation of the DAX Query Plan:
    http://aka.ms/ASTabPerf2012
    http://artisconsulting.com/Blogs/GregGalloway

  • DAX query

    Hi,
    I am having some challenging regarding a DAX query which do work but is very very slow, anyboy have any suggestion of another approach to speed up the query. I have found the problem is related to the crossjoin, however I need these fields.
    My Query is like this:
    EVALUATE
     CALCULATETABLE(
      FILTER(
       CROSSJOIN(
        VALUES('Project'[Projectnavn]),
        VALUES('Project'[Projectowner]),
        VALUES('Project'[Responsible]),
        VALUES('Project'[Area leader]),
        VALUES('Project'[Project leader]),
        VALUES('Activity'[Activity]),
        VALUES('Activity'[Start date]),
        VALUES('Activity'[End date]),
        VALUES('Activity'[Duration]),
        VALUES('Activity'[Percent completed]),
        VALUES('Resource'[Name])
       'Fact'[Number of Project] = 1
      'Activity'[Activity] = "Expected start period" || 'Activity'[Activity] = "Expected preparation start"
    I appreciate any suggestions
    Thanks!

    I believe I have found a problem With the model since I do get Resource name on all Project and therefor any possible outcome. However I know that not all Project have assigned Resources and I would have expected those to not appear. So I will have to check
    the model.
    Cheers

  • How to hide or filter out the row at break subtotal level

    Hi All,
    Need to know how to hide or filter out a row at break subtotal level.
    My Requirement is to sum up the first 20 business days total as Month total.
    This is a cross tab report, with Dates going from top to bottom, Securities going from left to right and Amount as the intersection of this two dimensions.
    So I have created a variables like this below
    RunningCount of Mtr Dt=ToNumber(RunningCount([Query 1].[Intrader Acct Mtrty Dt]))
    and
    MonthBreak=If [RunningCount of Mtr Dt] Between (1;20) Then 1 else 2
    Inserted this "MonthBreak" variable into the crosstab so it will give me each rowcount, then applied the break on this variable, so it split the first 20 rows and the rest of the remaining rows.
    Then applied Sum on the Amount column so it will add up the first 20 rows and then the remaining rows. Now I want to display only the subtotal row of the first 20rows and hide/filter the row subtotal line for remaining row numbers greater than 21.
    Did tried to do some thing using the alterers but no luck.
    Please help me fix this

    Hi Mathangi,
    When I apply
    =If ([MonthBreak] = 1) then Sum(Amount) else 0
    in the subtotal row, then nothing is changed.
    And one other thing I noticed is when we apply break on a column it footer should be same as the break value right. But here in my report the break footer is displaying 1 for both the cases for first 20 rows break and the rest from 21st rows.
    That is when I place  MonthBreak variable in the table.. which has values 1(for row 1 through 20) and 2 (for rows 21 to end of the report) then apply break on this MonthBreak column, its footer value are same for both the cases which is displaying as 1
    Do you know why this happens and to your information this is a cross tab report I am working on....

  • Tabular DAX Query for MINX, MAXX and AVGX

    Hi,
    I need to create three measure to get value of min, max and avg.
    For example, I have 3 columns in my table. I need to take minimum value of Column3 based on column2. If column2 value is 0, then we have to consider entire table data else only we have to consider
    Column1 Column2 Column3
    AAA         1      150
    BBB         1       50
    CCC         0       25
    DDD        1        40
    EEEE        0        70
    I need to take minimum,maximun and avg value of Column3 based on column2. If column2 value is 0, then we have to consider entire table data. IF column2 value is 1, then only we have to consider the row of column2=1.
    I expect the result as like below. Can you please help to find the DAX query for the measure.
    Column1 Column2 Column3  MinValue
    AAA         1      150            40
    BBB         1       50             40
    CCC         0       25             25
    DDD        1        40             40
    EEE         0         70            25
    EEE         0         70

    Hi,
    I have 3 columns in my table. I need to take minimum value of Column3 based on column2. If column2 value is 0, then i have to consider entire table data else only i have take minimum(column3) by considering rows of column2=1.
    Column1 Column2 Column3
    AAA         1      150
    BBB         1       50
    CCC         0       25
    DDD        1        40
    EEEE        0        70
    Try1:
    Min:=IF(Column2>0,MINX(FILTER(table,[column2]>0),[column3]),Min(Column3))
    Try2:
    Min:=MINX(IF(Column2>0,FILTER(table,[column2]>0),table),[column3]))
    Try3:
    Created Measure called Min1.
    Min1:=MINX(FILTER(Table,[Column2]>0),[Column3])
    And then i made this min1 measure to be hidden.
    Created another measure called Min2.
    Min2:=IF(ISBLANK([Min1]),MIN([column3]),[Min1])
    Both DAX query is not working. Can anyone help to have the correct DAX query to create Min measure based on the conditions.

  • R12: How to filter Open Item Revaluation Report based on GL Date

    Hi,
    Anybody know how to filter Open Item Revaluation Report based on GL Date from and GL Date to in R12?
    Since we just upgraded from 11.5.10 to 12.1.3 and found we cannot filter those report for specific date. It shown all data included the old data from 8 years ago also.
    We need to run the report only for specific date only. Please share with me if anyone know about this.
    Thanks.

    Pl do not post duplicates - R12: How to filter Open Item Revaluation Report based on GL Date

  • How to use the filter facet on af:column

    I have a column in my VO that is defined as a boolean and that shows as a selectBooleanCheckbox in my table. My table has filters on but above the boolean column it shows a regular input field.
    I checked the filter facet and i also put a selectBooleanCheckbox in it but i don't know how to set the values so the data will be filtered when the value of the checkbox changes.
    <f:facet name="filter">
                        <af:selectBooleanCheckbox id="cbFilt"/>
                      </f:facet>

    For an example that uses a selectOneChoice, easily adaptable to a selectBooleanCheckbox solution, please see:
    Re: how create selectOneChoice in filter facet of af:column _ jdeveloper11g.
    Regards,
    Matthew

  • While running the query how much time it will taken, I want to see the time

    Hi Folks
    I would like to know ... While running the query how much time it will be taken, I want to see the time? in WEBI XI R2.....
    Plz let me know  the answer.......

    Hi Ravi,
    The time a report runs is estimated based on the last time it was run. So you need to run the report once before you can see how long it will take. Also it depends on several factors... the database server could cache some queries so running it a second time immediately after the first time could be quicker. And there is the chance of changing filters to bring back different sets of data.
    You could also schedule a report and then check the scheduled instance's status properties and view how long a report actually ran.
    Good luck

  • Where to locate and how to use the filter thershould to binarized image

    Good morning friends. I am using
    Labview with VDM and let me know where to locate and how to use the
    filter thershould. Also that parameters used to binarized image captured
    via webcam and display it in black and white.
    Thank you very
    much.

    Is the image that you are getting a RGB one? Use color plane extraction and then use a binary threshold to convert it into a binary image. You can also directly use a color threshold and convert a rgb (color) image to a binary image.

Maybe you are looking for

  • Illustrator will no longer work after Yosemite upgrade!!!

    I downloaded Yosemite on my Macbook Pro and now Illustrator will no longer work. A warning pops up that I need the newest Java runtime which I already have. What should I do? Please help

  • Photo quality problem in iWeb 08?

    I'm still using iWeb '06 but thinking of upgrading. When the '08 version was new I saw some reports that photos handled by '08 were of lesser quality than that provided by iWeb '06. Is there any truth to this? If so, was it fixed? My main use of iWeb

  • Broken Charging Port

    Hi, I am with Bell. Last year i had boughten my first bb in April, a blackberry Style. Four months later the charging port broke. First it started off that I needed to have the cable on a certain angle to charge then it stopped working altogether. I

  • I need help now.

    This window came up when I try to register Lightroom 5,5...I was bought it for three days ago and I not happy :-( because I have to use it now. Electronic Registration Failed Sending your registration information to Adobe has failed.Check your intern

  • BT Mail / Google Chrome Problem

    Since Monday of this week, if I leave a message open and select my inbox to look at other messages, I am automatically logged out. BT tells me this is an issue with Chrome, and indeed I don't have the same problem with Internet Explorer. Has anybody