We have a problem to compare Date dimension members with some arbitrary date constant in mdx queries.
I want compare Date dimension members.
We take an arbitrary constant from user and need to do a filtering of some dimension comparing to that value but not knowing the exact values in the dimension, meaning the value doesn't have to belong to the member's list of the dimension.(because we don’t have all member in time dimension.)
our queries doesn't work correctly:
SELECT
{[Measures].[Trade Cnt] } ON 0,
bottomcount(FILTER([VW Dim Customer Broker Branch].[Reception Date].[Reception Date],
[VW Dim Customer Broker Branch].[Reception Date].Currentmember.MemberValue < '2009-08-10T00:00:00'),1) ON 1
FROM
[DV Present]
Yes,That is.
my date format is:
[VW Dim Customer Broker Branc Firm].[Reception Date].&[2009-08-05T00:00:00]
Related
I have a column Sales and a column date, I want to use the average sales from month 10 (October) as reference to compare with the others months.
I made a calculated field Sales_december like avgIf(Sales,date<parseDate('10/31/2022','MM/dd/yyyy'))
*10/01/2022 is the first date in the date column
I'm using Sales_december as a reference line in a line chart, every time I filter the date to a specific month Sales_december goes to zero. The only solution I found was to create a field Sales_december_const with the average value of Sales_december, Ex.: Sales_december_const =2000
avgOver(ifelse({date} < parseDate('10/31/2022', 'MM/dd/yyyy'), {sales}, NULL), [], PRE_FILTER)
You need to use PRE_FILTER in this position to avoid the filters affecting the value.
PRE_FILTER and PRE_AGG are not supported with avgif, but using ifelse here should work how you have it set up in your calculation.
I want to use the selected slicer value in string format to filter rows in a table in a visual.
So, I created the following measure:
SlicerVal = ALLSELECTED(Table[Column1])
The follow up measure is as follows:
TotalRows = CALCULATE(COUNTROWS(Table),filter(Table, Table[Column2] = [SlicerVal]))
However.. This returns completely different data. When hardcoding the string value the correct data is returned, like in the example below:
TotalRows = CALCULATE(COUNTROWS(Table),filter(Table, Table[Column2] = "A"))
Is there a way to convert the measure value to a string somehow, which can be used dynamically to correspond the string value filter to the selected slicer value?
How about this?
TotalRows = CALCULATE(COUNTROWS(Table),filter(Table, Table[Column2] IN ALLSELECTED(Table[Column1])))
[Question: are you intentionally filtering on all selected elements from Column1 when applying a conditions onto Column2? I have no idea about your use-case, that's why -- for safety reasons -- I'm asking...]
I am trying to get Planned % complete on data date from Planned Start/Finish Date using if function
if ([Plan_Actual_Start_Date]> [Data Date]) then 0 else ((([Data Date]-[Plan_Actual_Start_Date])+1/(([Plan_Actual_Finish_Date]-[Plan_Actual_Start_Date])+1)))
I get an error as below
How can I overcome this error?
Datatypes are important in Power Query.
When you subtract one date from another, the result is a duration data type.
In order to add a number to a duration, you can first convert the duration to a number.
Modify your formula segments to something like: Duration.Days([Data Date]-[Plan_Actual_Start_Date]) +1
I have a query in Power BI that takes two parameter: Start Date and End Date.
Whenever I pass these Dates it return a table of Date that contain few columns created according to this range of date such as Date, QuarterofYear, Year, MonthName......etc.
Can we create a mapping data flow in ADF that takes two parameter as input and return a calculated table according to provided dates?
Is there any function that return the range of dates?
For your request: "I want that I pass two date Start Date and End Date in ADF Mapping Data Flow , and Data flow will Create a column such as "Date" that contain that number of Date rows. Is there any function for this? Exam. Start Date=20-01-2019, End Date=20-01-2020 Then Date Column Values should be: 20-01-2019 21-01-2019 ......... ......... 20-02-2020", according the Data Factory documents and my experience, the answer is no, we can't achieve it in Data Flow.
There is a solution to this, but it is a bit tricky.
TL;DR
The general data flow looks like this:
We need a dummy source with exactly one row which contains whatever.
Then we derive a column where we use the mapLoop() expression to create an array of all the dates we want to get rows for.
Finally, we need to flatten the array column which will result in one row per array entry and thus one row per date.
Walkthrough
Source dummy
Each dataflow needs a source and we need exactly one row to make our dataflow work. To achieve this I've created a dataset called empty of type CSV in my data lake which has this content:
empty
""
This is our source definition:
And its result looks like this:
Derived column days
This is where the magic happens!
We create a new column dates which is an array of all the dates we want to have in our date table:
In this scenario we want a date table starting on 2019-01-01 and reaching one year into the future. The full expression looks like this:
mapLoop(
addDays(currentDate(), 365) - toDate(2019-01-01),
addDays(toDate(2019-01-01), #index)
)
This is what happens here:
the mapLoop() function builds an array of elements. You specify the number of elements you want to have and the lambda expression to calculate each of the elements. For example, mapIndex([1, 2, 3, 4], #item + 2 + #index) results in [4, 6, 8, 10]
addDays(currentDate(), 365) - toDate('2019-01-01') is the number of days between our start (2019-01-01) and end date (1 year in the future from now) and thus the number of dates we want to have in our resulting array.
addDays(toDate(2019-01-01), #index) calculates each array item by adding #index days to our start date. This is executed for the number of days we've calculated before and #index is the array position. Thus, the first element of the array will be 2019-01-01 + 1, the second 2019-01-01 + 2 and so on.
Our stream now has these columns:
Flatten
Finally, you need a flatten transformation which will expand each item in your array to its dedicated row. We can also dismiss the useless empty column in this step:
And this finally results in what we wanted to achieve:
References
Data transformation expressions in mapping data flow
I am trying to add two currency columns in a calculated column but am getting a #NULL! error.
This seems pretty straightforward but its my first time doing this in SharePoint.
SharePoint 2010 with Excel Services available.
Have create List with required columns:
Approved Value column Type = Currency
Pending Value column Type = Currency
Total Value column
Calculated (calculation based on other columns)
Type = Currency
Formula: =[Approved Value]+[Pending Value]
The values in other columns are indeed currency, but the Total shows #NULL! for all items.
I can't see anything done incorrectly.
What should I be looking for to resolve this problem?
Try using the ISBLANK function to previously check if any of the value is null.
Reference: ISBLANK function
I ended up using NZ(Value, 0)
=NZ([Approved Value],0)+NZ([Pending Value],0)
Though not sure how NULLs ended up in field or why SharePoint couldn't deal with them without this special treatment.