I need your help , i need to calculate difference between dates, with result in days.
so i have a factorder with sk_date2 and sk_date1, both of them FK's to a Dim Date (but relationship not established in PP), FK has this format 20120701 (yyyymmdd) and in this table date 01-07-2012 00:00:00
when dates aren't defined they have -1. I've also noticed that i can make the difference immediatly using the keys, which simplifies the calculation.
so i have to do something like:
test:=CALCULATE
(('Fact Order'[sk_date2] - 'Fact Order'[sk_date1]); ('Fact Order'[sk_date2]>=1); ('Fact Order'[sk_date1]>=1))
/
CALCULATE(COUNTROWS('Fact Order'); 'Fact Order'[sk_date2]>=1; 'Fact Order'[sk_date1]>=1)
Questions:
1- This has an syntax error. Probably i can't write the numerator as i did.
2- How would you write this query?
3- i can create a new column with the difference between dates, and them sum it up and divide by the total, but my excel file is growing big and i would like to avoid new columns. Adding new columns contribute to size and, in some way, to the complexity of the powerpivot model, right?
4 - if i want to include the lines where some date is not defined (and use this "unfinished" orders in calculation), is there anyway to substitute -1 with today's date and simulate the FK?
For ex. order 1234 has sk_date2 = -1, and i force the calculation to use (as i am on 06-03-2014) 20140306 and make the difference to sk_date1 ...?
Regards
so i have a factorder with sk_date2 and sk_date1, both of them FK's to a Dim Date (but relationship not established in PP), FK has this format 20120701 (yyyymmdd) and in this table date 01-07-2012 00:00:00
when dates aren't defined they have -1. I've also noticed that i can make the difference immediatly using the keys, which simplifies the calculation.
so i have to do something like:
test:=CALCULATE
(('Fact Order'[sk_date2] - 'Fact Order'[sk_date1]); ('Fact Order'[sk_date2]>=1); ('Fact Order'[sk_date1]>=1))
/
CALCULATE(COUNTROWS('Fact Order'); 'Fact Order'[sk_date2]>=1; 'Fact Order'[sk_date1]>=1)
Questions:
1- This has an syntax error. Probably i can't write the numerator as i did.
2- How would you write this query?
3- i can create a new column with the difference between dates, and them sum it up and divide by the total, but my excel file is growing big and i would like to avoid new columns. Adding new columns contribute to size and, in some way, to the complexity of the powerpivot model, right?
4 - if i want to include the lines where some date is not defined (and use this "unfinished" orders in calculation), is there anyway to substitute -1 with today's date and simulate the FK?
For ex. order 1234 has sk_date2 = -1, and i force the calculation to use (as i am on 06-03-2014) 20140306 and make the difference to sk_date1 ...?
Regards