Dax Calculate column even when there is no record at a date

We are creating a powerpivot model based on a table with data about worktasks of our employees.
This is simplified our input:
Tasknr date started dateended
1 20140101 20140201 (yyyymmdd)
2 20140102 20140103
3 20140104 20140108
Etc
We created two measures to calculate how many tasks are opened and closed per day. That was no problem, but now the tricky part. We also want to know each day how many tasks are
still open, even on days that no tasks are opened (or closed).
My approach was to create a calculated column to determine how many tasks are opened up to that date and subtracted the closed tasks and end up with the tasks that are open. That
seems to be working :
=COUNTROWS(FILTER(Tasks; Tasks[Open]<=EARLIER(Tasks[Open]))) - COUNTROWS(FILTER(Tasks; Tasks[Close]<=EARLIER(Tasks[Open])))
When I load this to the excel pivot I end up with this:
Row Labels| Opened | Closed | Open not finished
1/1/2014
        1         
0          1
1/2/2014        
1          0         
2
1/3/2014
        0         
1         0
1/4/2014
        1         
0         2
The line with 1/3/2014 should have 1 in the column [opened not finished], but because that calculation is linked to the opendate column, not to the closed and 3/1/2014 no task
was opened, there is no value. On days that no tasks are opened or closed there even is no line at all although there could be tasks that are still open.
I need a mechanism that calculates the value even when there are no records
on a particular day. Our users want to be able to view the results on any date they select.
I have considered a second table with all the dates and calculate columns from the task-table but are there other ways to do this? I searched this forum but did not find an answer
so far.

Hi Jacob,
In our company we have a standard date table that is included in all of our models. What I didn't want to do in this case was to extend that table with calculated fields to solve this issue. Alternative was to create a new date table with the calculated
fields I needed. But I don't like that also so what I did was rewrite the sql that loaded the data into the pivot so that the measures were calculated at the load. But I am also not happy with that solution because of maintanance and performance reasons. My
feeling is that there must be a way to solve this with only dax in the loaded table.
Jacob's answer does exactly what you want. The DAX expression in his response is a measure which you could put in your Tasks table. You don't need to alter your date dimension in any way.
The key to this technique is that the date table cannot have an active relationship to your Tasks table. (although you could have an inactive relationship and then you could use the USERELATIONSHIP function to make other measures easier to calculate)
Translating Jocob's measure into something against a 'Tasks' table would looks like the following:
=
CALCULATE (
COUNTROWS ( Tasks ),
FILTER (
Tasks,
Tasks[Open] <= MAX ( Calendar[Date] )
&& Tasks[Closed] >= MAX ( Calendar[Date] )
http://darren.gosbell.com - please mark correct answers

Similar Messages

  • Database Instance Using Swap Space even When There is Plenty of Free RAM

    Hi,
    I am facinga strange issue in oracle on solaris 5.10
    Platform:solaris 5.10
    Database version:11.2.0.1.0
    Our database Instance Using Swap Space even When There is Plenty of Free RAM.
    We have 80GB of physical RAM, 32GB is set to oracle SGA_MAX_SIZE
    memory parameters:
    memory_max_target big integer 32G
    memory_target big integer 32G
    sga_max_size big integer 32G
    sga_target big integer 32G
    but still oracle is taking memory from swap even though we have enough physical memory.
    please find the top output
    load averages: 0.09, 0.18, 0.84 01:07:49
    134 processes: 133 sleeping, 1 on cpu
    CPU states: 99.4% idle, 0.4% user, 0.3% kernel, 0.0% iowait, 0.0% swap
    Memory: 80G real, 69G free, 35G swap in use, 49G swap free
    PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
    1052 oracle 13 59 0 95M 66M sleep 13:16 0.07% oraagent.bin
    10256 oracle 1 59 0 32G 835M sleep 0:00 0.03% oracle
    1227 oracle 15 59 0 78M 56M sleep 4:27 0.02% ocssd.bin
    9524 vector1 112 59 0 1704M 776M sleep 45:04 0.02% java
    988 oracle 38 59 0 119M 92M sleep 3:00 0.02% ohasd.bin
    1297 oracle 1 101 -20 453M 390M sleep 2:47 0.02% oracle
    1765 oracle 1 101 -20 32G 329M sleep 2:45 0.02% oracle
    10258 oracle 1 59 0 32G 345M sleep 0:00 0.02% oracle
    10259 oracle 1 59 0 3400K 2024K cpu/20 0:00 0.01% top
    1777 oracle 1 59 0 32G 342M sleep 1:14 0.01% oracle
    1246 oracle 6 59 0 56M 44M sleep 1:22 0.01% diskmon.bin
    1803 oracle 1 59 0 32G 514M sleep 0:30 0.01% oracle
    1215 oracle 15 59 0 71M 46M sleep 1:12 0.00% cssdagent
    1307 oracle 1 59 0 453M 390M sleep 0:45 0.00% oracle
    1217 oracle 11 59 0 81M 49M sleep 0:35 0.00% orarootagent.bi
    Vmstat output:
    $vmstat 5 5
    kthr memory page disk faults cpu
    r b w swap free re mf pi po fr de sr s3 s3 s3 s3 in sy cs us sy id
    0 0 0 53698448 73900568 20 81 32 6 5 0 1 -0 0 1 -0 2235 1447 1984 1 0 99
    0 0 0 51196160 72037552 1 13 0 0 0 0 0 0 0 0 0 2505 1403 2204 0 0 100
    0 0 0 51193488 72035864 55 380 0 0 0 0 0 0 0 0 0 2487 2143 2203 0 1 99
    0 0 0 51183856 72030176 0 0 0 3 3 0 0 0 0 0 0 2496 1370 2182 0 0 99
    0 0 0 51182648 72029112 22 117 0 0 0 0 0 0 0 0 0 2503 1408 2193 1 0 99
    $cat /etc/release
    Solaris 10 10/09 s10s_u8wos_08a SPARC
    Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
    Use is subject to license terms.
    Assembled 16 September 2009
    I refered the metalink document id: [ID 761960.1]
    Database Instance Using Swap Space When There is Plenty of Free RAM metalink note [ID 761960.1]
    and tried the disabling the sga_max_size and memory_max_target and memory target with all different combination but no use.
    We have one more box where same setup was configured in solaris platform but there the above memory parameters are not disabled but it is not using swap space it takes memry only from physical RAM
    Can any one throw some lights on this issue. It wopuld be great if I come to know where the exact problem
    Thanks in advance
    With Regards,
    Boobathi P

    Hi,
    I didn't say I am not using 11gr2 memory parameters I am using all the automatic memory parameters but the thinks is as per the metalink note I tried by disabling the automatic memory parameters. but that didn't help me in preventing unnecessary swap usage. So I reverted. now it is using automatic memory parameters.
    so What is the solution for this?
    With Regards,
    Boo

  • GRC 5.3: CUP asks to perform risk analysis even when there are no risks in request

    Hi All,
    We recently upgraded from GRC 5.3 SP13 to SP22.
    The one issue which we are facing after upgrade is that now CUP is forcing approvers to do Risk Analysis, even when there are no risks in the CUP Request, that is Risk Tab is Green.
    Previously approvers were able to approve requests without doing risk analysis, if there were no risks in the request.
    CUP used to force them to do risk analysis only when there were risks associated with requests.
    But now, it is forcing approvers to perform risk analysis, even if there are no risks, i.e. approvers are not able to approve requests without any risks without doing risk analysis.
    Please advise.
    Thanks
    Aditi

    Hi,
    Can you check if any change is made in Configuration -> Workflow -> Stage -> Approvers
    Regards,
    Claudio

  • PRI channel busy issue , even when there are no active calls

    Hi All ,
    i using VWIC-2MFT - E1 CARD with VG. one PRI is working fine but on another PRI we are facing busy channel problem , even when there is no active calls , actually channels are not being free after disconnecting call. when we restart the gateway its startworking for some time ...
    i already replaced that card .
    please advice

    I believe that this post should be made to the Unified Communications and Video forum.
    Would please you repost to that group.
    Thanks

  • Allocated heap memory goes up even when there is enough free memory

    Hi,
    Our Java application's memory usage keep growing. Further analysis of the heap memory using JProbe shows that the allocated heap memory goes up even when there is enough free memory available in the heap.
    When the process started, allocated heap memory was around 50MB and the memory used was around 8MB. After few hours, the inuse memory remains at 8MB (slight increase in KBs), but the allocated memory went upto 70MB.
    We are using JVM 1.5_10. What could be the reason for heap allocation going up even when there is enough free memory available in heap?
    -Rajesh.

    Hi Eric,
    Please check if there is any error or warning in the Event Viewer based on the data time?
    If there is any error, please post the event ID to help us to troubleshoot.
    Best Regards,
    Anna

  • USB not recognized - even when there's no USB device at all (Windows 7, Pavilion dv7)

    Since a few days now I get the message
    'The USB-device was not recognized: One of the USB-devices connected to this computer does not work correclty. The device has not been recognized'.
    It keeps popping up from my right corner below, every 5 seconds if I don't click it. When I click the message, I get a list of USB devices (ports) there are available. There's one 'Unknown device'. Maybe it has something to do with the finger scan (biometric)? This hasn't been working very good lately..
    Even when there's no single USB device installed (normally I have a mouse and a Targus laptop chill mat installed as USB devices), it keeps popping up. I tried deleting the USB port from the list (or uninstall it) in Device control, but it seems it keeps happening.
    I suddenly got it, I did nothing specific of did not connect any strange devices (except for a projector on the external monitor exit, but that has nothing to do with USB). I also hear the sound for connecting and disconnecting USB devics randomly when I'm on my laptop.
    Anyone has any idea?
    Thanks
    HP Pavilion dv7 Notebook PC
    LE902EA#UUG
    Windows 7 64 bit
    This question was solved.
    View Solution.

    The solution can be found here

  • Constant notifications even when there's nothing to be notified of. Galaxy S5.

    Ever since I updated my Samsung Galaxy s5 yesterday I have been getting constant message tones even when there's nothing to be notified of. I have restarted my phone more than enough times to know its not that causing issues.

        josh366,
    This definitely seems strange that you are receiving these notifications without having any type of texts, or emails, or any other types of notifications. Since the software upgrade, have you downloaded any new apps? Let's also try to power the device off, remove the SIM card and wait for about 30-60 seconds and then put the SIM back in and power back on. Keep us posted!
    ErinW_VZW
    Follow us on Twitter @VZWSupport

  • Quota dedcuting even when there is no quota

    i got this problem,
    I have a absence type A whose quota is deducting from absence type B. but even when there is no quota ,the system is deducting the quota from someother absence type i.e. C
    Kindly help.....

    thks all...........its solved .in dedcution i jus need to chose "no further assignment"
    Please Close the thread if you issue  is solved
    Edited by: Sikindar on Feb 2, 2010 11:55 AM

  • Cd icon shows even when there is no cd present. I tried ejecting it and inserting another cd and the cd gets ejected. what is the solution to this

    icon shows even when there is no cd present. I tried ejecting it and inserting another cd and the cd gets ejected. what is the solution to this

    Jailbreaking iOS can't be discussed in this forum.

  • How do I print some value when there is no record against field

    hi,
    I have two queries and a link between two queries .columns selected for query are source to the fields in layout. In one of the case i have record for master table but the detail field is left blank because there is no record against it(its not null)
    How do i display "0" where there is no record in detail. the columns of both the query are in same record . I can't assign "0" when null because there is no record so its not null.
    Thanks in advance
    Rama

    Create a summary column in the parent query which counts the records in the child query. This will be zero when there are no records in the child query. Put this field on the page and in the format trigger use "RETURN :cs_count = 0;" to ensure the field is not visible except when its value is zero.

  • Every time I try and update my iphone 4 to ios 7.1 in iTunes 11.1.5 it says "connection reset" even when there is no problem with my connection

    I have an iPhone 4. I use iTunes 11.1.5 on my Mac. I am trying to update to ios 7.1 through iTunes, but every time I do that, I get a "connection reset" error, even when I know there has been no problem with my connection.
    The exact error message is as follows:
    "There was a problem downloading the software for the iPhone "Anne's iPhone". The network connection was reset.
    Make sure your network settings are correct and your network connection is active, or try again later."
    I have checked several times. There is no problem with the connection, and I have tried to download the software several times today.
    Any help you can give me would be appreciated.

    Just managed to successfully download the update, having retried five or six times. I did unplug my phone while the download was taking place (had asked iTunes to download only, not to update) -- suspect this had no bearing on it whatsoever, and that persistence is the only way here.

  • Hi, since doing the latest update my phone makes a strange noise everytime i send or recieve a text even when there is no text tone set?

    hi, since updating my iphone 3gs with latest software it makes a noise when sending/recieving texts even though there is no text tone selected

    Hi Thisslowgt,
    If you are having issues with your iPhone making unexpected sound signals, you may want to try some things to troubleshoot.
    First, quit all running applications and test again -
    iOS: Force an app to close
    Next, I would try restarting the iPhone -
    Turn your iOS device off and on (restart) and reset
    If the issue is still present, you may want to restore the iPhone as a new device -
    iOS: How to back up your data and set up your device as a new device
    Thanks for using Apple Support Communities.
    Best,
    Brett L  

  • ORA-00900 when there is huge quantity access to Data Base

    Hi
    I have some Java programs which access to the same Data Base Oracle 11gR2 from diferent computers and diferent Operative System.
    in a normal execution everything is working but when I want to test the 'stress' in the data base I execute many concurrent programs. The problem is that when I execute too many programs the data base answer me 'java.sql.SQLException: ORA-00900: sentencia SQL no valida' (I´m sorry the spanish expresion, I don´t know the english correspondence)
    The SQL sentences are static.
    Do you know why? and do you know the solution?
    Thanks you for your answers
    Pablo José Izquierdo

    hi, thank for your answer
    I enable a logging in my Java program and after the execution I write the sql sentence which causes the exception in my SQLplus and it´s correct. The programs execute the same 4 sentences about 50 time every second (more 200 access every second and every program) and it´s only return a problem when I have too many programs.
    It´s only happens sometimes, no always, but the execution is very long and I find the problem at some point in the same
    The database is Autocommit and the sentences are on the same table but on diferente values.

  • Offline Browsing - Safari insists on re-loading even when there is Internet

    Safari insists on re-loading web pages when offline. I have cleared the cache, etc. and otherwise reset Safari, and it seems to work for a short while, but eventually Safari is back to its old tricks every time I switch to another web page or application, and insists on re-loading a page or pages that were already loaded.
    This is most frustrating. It happens whether or not I have an Internet connection or not. Case in point, I had loaded a number of web pages of newsgroups and articles I wanted to read on the plane, as well as my e-mail. Got on the plane, played a game, checked my mail, replied to some to be sent when I was again connected to the Internet, then switched over to read the webpages I had cached, and BOOM, every single one of them reloaded to blank pages indicating that the Internet was not available. pressing the back button just resulted in the same message.
    What is up with this? Is there a way to disable Safari from forced re-loads? Remember the good old days of the save for off-line browsing button?
    Or is this just poor memory management? Does the iPad not have enough RAM to support its abilities? Are the multi-tasked apps loaded into RAM the culprit? If so should I force-quit all loaded apps before I start caching web pages? And if thats the case is there a way to force-quit all open apps rather than go through each one?

    Yikes!! It's Steve Jobs' 128K Macintosh all over again!! At least there are no endless floppy swaps!
    Thanks, I figured that was the case. So basically, it's not all the web pages I have open, but all the RAM being tied up in something else. I suspect multi-tasking is a bad thing for off-line browsing. I will try quitting everything I am not using which is open in the background ... And here's where Apple should have included an all quit option. However, I think the bigger problem with Safari, is that it does not store the cached pages on the flash drive, but only in RAM, so unlike an e-mail draft, which will be there even if Mail crashes, the cache disappears as soon as the RAM runs low. This is really unacceptable. If this is how it's going to work, they need to bring back the "save for offline reading" option.
    For now, I'm starting to think there should be a memory monitor app, so that users can address these kinds of issues.

  • Price Variance hitting PPV account even when there is stock.

    Dear Experts,
    We have scenario where stock is transferred from one plant to another within the same company code. However the price difference between invoice and PO price is being posted to PPV account eventhough there is Material Stock.
    Your advice is highly appreciated.
    Regards
    Adithya 

    Hi Aditya,
    Sorry for interupting between, please let me share some views on ML, anyhow consider Ajay's input as final.
    Let us assume this way:
    Present your RM price as 100 Rs.
    Your PO is raised for 150 Rs and the stock is 20 KG
    When you have your GR, the entry you might see is...
    Dr. RM stock account (20*100)                        2000
    Dr. Purchase price variance ((150-100)*20)    1000
    Cr. GR/IR                                                        -3000
    Still stock has not been issued to any production order or any cost center etc, so RM stock left with you is 20 KG
    So this might be your scenario, and you are expecting the purchase price diffference should be posted to stock, instead of purchase price variance. Since price control you have made as S (that understood from earlier talk), it is the right behaviour of the system.
    If you want to make the system to consider the difference to stock, then obvously you need to have ML.
    Please have a look at ML process, how system is going to roll up the difference.
    Again assume that inorder to manufacture a particular FG, you are using the above RM of 15 KGs.
    So the RM left at stock after issue will be 5 Kgs
    If you maintain all the settings related to actual costing (ML), at the month end we will be performing ML process, where we will be having different steps to go, among those for the time being these two are important as you want to see the diffence updation to stock.. (explaining only for purchase price differences, but in real system is going to have preliminary value, purchase price difference, production variance and exchange rate differences also)
    single level price determination: by this system is going to calculate what is the amount have to be considered for the respective level (here it is RM) and how much amount to be distributed to next level
    Since 5 Kgs of stock is left out, system is going to allocate at RM level (total difference amount * inventory remaining/total inventory) i.e. (1000*5/20) = 250
    This amount of 250 will be added to RM stock
    at the same time system is going to calculate what amount to be distributed to higher level also (becuase already we issued 15 kgs to FG manufaucturing and at the time of issue system has considered 100 Rs as issue price, but in real it should be issued considering PPV also)
    so system is going to calculate and specifies what is the amount to be rolled up to higher level here it is (1000*15/20) = 750, but in this step system will not add 750 Rs to FG value
    The adding of rollup actual costing is done in the next step i.e. multi level price determination
    I hope you understand.....
    Regards..
    Jose

Maybe you are looking for