topic DAX Measure to count if two date conditions are met in DAX Commands and Tips
https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601840#M75218
<P><SPAN>I have been utilizing these forms for a few months now, and it has been an amazing source of help to learn how to use Power BI.</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>I am currently struggling with coming up with DAX Measure that I would use to show a count of rows that match two date requirements. So, for the row to be counted the row needs one column value to be greater than the day the count is being done for, and then it would need to check an additional column and see if the date in that column is less than the day the count is being done for. If both are true, it is counted. If either or both are false, it is not counted</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>For example, using the data set below, I am trying to write an expression that will show the number of invoices open on every day of the time period. For this set it would be January 4th through January 14th. To do this I need to count the number of rows where the Created-on Date is less than the date of the count and that the Closure date is greater than the date of the count.</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>For example, at the end of January 6th there would be 8 invoices open</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>I'm hoping to use this to look at how the number of invoices opened changed day by day. Thank you in advance for any help or any ideas someone may have.</SPAN></P><P> </P><TABLE><TBODY><TR><TD>InvoiceNumber </TD><TD> Invoice Created On</TD><TD>Invoice Closure date</TD><TD>Material description</TD></TR><TR><TD>88912</TD><TD>1/4/2022</TD><TD>1/5/2022</TD><TD>Item 3</TD></TR><TR><TD>89025</TD><TD>1/4/2022</TD><TD>1/13/2022</TD><TD>Item 14</TD></TR><TR><TD>88792</TD><TD>1/4/2022</TD><TD>1/14/2022</TD><TD>Item 17</TD></TR><TR><TD>88767</TD><TD>1/4/2022</TD><TD>1/28/2022</TD><TD>Item 4</TD></TR><TR><TD>89201</TD><TD>1/5/2022</TD><TD>1/18/2022</TD><TD>Item 11</TD></TR><TR><TD>89341</TD><TD>1/5/2022</TD><TD>1/6/2022</TD><TD>Item 17</TD></TR><TR><TD>89487</TD><TD>1/5/2022</TD><TD>1/31/2022</TD><TD>Item 5</TD></TR><TR><TD>89399</TD><TD>1/5/2022</TD><TD>2/1/2022</TD><TD>Item 11</TD></TR><TR><TD>89694</TD><TD>1/6/2022</TD><TD>1/19/2022</TD><TD>Item 11</TD></TR><TR><TD>89689</TD><TD>1/6/2022</TD><TD>2/2/2022</TD><TD>Item 9</TD></TR><TR><TD>90060</TD><TD>1/7/2022</TD><TD>1/25/2022</TD><TD>Item 6</TD></TR><TR><TD>90294</TD><TD>1/7/2022</TD><TD>2/3/2022</TD><TD>Item 3</TD></TR><TR><TD>90269</TD><TD>1/7/2022</TD><TD>2/5/2022</TD><TD>Item 10</TD></TR><TR><TD>90079</TD><TD>1/7/2022</TD><TD>2/6/2022</TD><TD>Item 6</TD></TR><TR><TD>90345</TD><TD>1/8/2022</TD><TD>1/30/2022</TD><TD>Item 13</TD></TR><TR><TD>90847</TD><TD>1/10/2022</TD><TD>1/26/2022</TD><TD>Item 1</TD></TR><TR><TD>90753</TD><TD>1/10/2022</TD><TD>2/7/2022</TD><TD>Item 6</TD></TR><TR><TD>90782</TD><TD>1/10/2022</TD><TD>2/8/2022</TD><TD>Item 6</TD></TR><TR><TD>91275</TD><TD>1/11/2022</TD><TD>1/15/2022</TD><TD>Item 1</TD></TR><TR><TD>90903</TD><TD>1/11/2022</TD><TD>1/27/2022</TD><TD>Item 6</TD></TR><TR><TD>90885</TD><TD>1/11/2022</TD><TD>2/9/2022</TD><TD>Item 6</TD></TR><TR><TD>91272</TD><TD>1/11/2022</TD><TD>2/16/2022</TD><TD>Item 1</TD></TR><TR><TD>91619</TD><TD>1/12/2022</TD><TD>1/20/2022</TD><TD>Item 6</TD></TR><TR><TD>91373</TD><TD>1/12/2022</TD><TD>1/21/2022</TD><TD>Item 11</TD></TR><TR><TD>91580</TD><TD>1/12/2022</TD><TD>2/4/2022</TD><TD>Item 7</TD></TR><TR><TD>91759</TD><TD>1/12/2022</TD><TD>2/10/2022</TD><TD>Item 11</TD></TR><TR><TD>91310</TD><TD>1/12/2022</TD><TD>2/12/2022</TD><TD>Item 12</TD></TR><TR><TD>91583</TD><TD>1/12/2022</TD><TD>2/13/2022</TD><TD>Item 8</TD></TR><TR><TD>92353</TD><TD>1/13/2022</TD><TD>1/16/2022</TD><TD>Item 2</TD></TR><TR><TD>92170</TD><TD>1/13/2022</TD><TD>1/17/2022</TD><TD>Item 4</TD></TR><TR><TD>92290</TD><TD>1/13/2022</TD><TD>1/22/2022</TD><TD>Item 15</TD></TR><TR><TD>92351</TD><TD>1/13/2022</TD><TD>1/29/2022</TD><TD>Item 2</TD></TR><TR><TD>91861</TD><TD>1/13/2022</TD><TD>2/11/2022</TD><TD>Item 3</TD></TR><TR><TD>91993</TD><TD>1/13/2022</TD><TD>2/14/2022</TD><TD>Item 3</TD></TR><TR><TD>92203</TD><TD>1/13/2022</TD><TD>2/15/2022</TD><TD>Item 16</TD></TR><TR><TD>92363</TD><TD>1/14/2022</TD><TD>1/23/2022</TD><TD>Item 17</TD></TR></TBODY></TABLE>Sat, 25 Jun 2022 20:17:04 GMTBooRadley2022-06-25T20:17:04ZDAX Measure to count if two date conditions are met
https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601840#M75218
<P><SPAN>I have been utilizing these forms for a few months now, and it has been an amazing source of help to learn how to use Power BI.</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>I am currently struggling with coming up with DAX Measure that I would use to show a count of rows that match two date requirements. So, for the row to be counted the row needs one column value to be greater than the day the count is being done for, and then it would need to check an additional column and see if the date in that column is less than the day the count is being done for. If both are true, it is counted. If either or both are false, it is not counted</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>For example, using the data set below, I am trying to write an expression that will show the number of invoices open on every day of the time period. For this set it would be January 4th through January 14th. To do this I need to count the number of rows where the Created-on Date is less than the date of the count and that the Closure date is greater than the date of the count.</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>For example, at the end of January 6th there would be 8 invoices open</SPAN></P><P><SPAN> </SPAN></P><P><SPAN>I'm hoping to use this to look at how the number of invoices opened changed day by day. Thank you in advance for any help or any ideas someone may have.</SPAN></P><P> </P><TABLE><TBODY><TR><TD>InvoiceNumber </TD><TD> Invoice Created On</TD><TD>Invoice Closure date</TD><TD>Material description</TD></TR><TR><TD>88912</TD><TD>1/4/2022</TD><TD>1/5/2022</TD><TD>Item 3</TD></TR><TR><TD>89025</TD><TD>1/4/2022</TD><TD>1/13/2022</TD><TD>Item 14</TD></TR><TR><TD>88792</TD><TD>1/4/2022</TD><TD>1/14/2022</TD><TD>Item 17</TD></TR><TR><TD>88767</TD><TD>1/4/2022</TD><TD>1/28/2022</TD><TD>Item 4</TD></TR><TR><TD>89201</TD><TD>1/5/2022</TD><TD>1/18/2022</TD><TD>Item 11</TD></TR><TR><TD>89341</TD><TD>1/5/2022</TD><TD>1/6/2022</TD><TD>Item 17</TD></TR><TR><TD>89487</TD><TD>1/5/2022</TD><TD>1/31/2022</TD><TD>Item 5</TD></TR><TR><TD>89399</TD><TD>1/5/2022</TD><TD>2/1/2022</TD><TD>Item 11</TD></TR><TR><TD>89694</TD><TD>1/6/2022</TD><TD>1/19/2022</TD><TD>Item 11</TD></TR><TR><TD>89689</TD><TD>1/6/2022</TD><TD>2/2/2022</TD><TD>Item 9</TD></TR><TR><TD>90060</TD><TD>1/7/2022</TD><TD>1/25/2022</TD><TD>Item 6</TD></TR><TR><TD>90294</TD><TD>1/7/2022</TD><TD>2/3/2022</TD><TD>Item 3</TD></TR><TR><TD>90269</TD><TD>1/7/2022</TD><TD>2/5/2022</TD><TD>Item 10</TD></TR><TR><TD>90079</TD><TD>1/7/2022</TD><TD>2/6/2022</TD><TD>Item 6</TD></TR><TR><TD>90345</TD><TD>1/8/2022</TD><TD>1/30/2022</TD><TD>Item 13</TD></TR><TR><TD>90847</TD><TD>1/10/2022</TD><TD>1/26/2022</TD><TD>Item 1</TD></TR><TR><TD>90753</TD><TD>1/10/2022</TD><TD>2/7/2022</TD><TD>Item 6</TD></TR><TR><TD>90782</TD><TD>1/10/2022</TD><TD>2/8/2022</TD><TD>Item 6</TD></TR><TR><TD>91275</TD><TD>1/11/2022</TD><TD>1/15/2022</TD><TD>Item 1</TD></TR><TR><TD>90903</TD><TD>1/11/2022</TD><TD>1/27/2022</TD><TD>Item 6</TD></TR><TR><TD>90885</TD><TD>1/11/2022</TD><TD>2/9/2022</TD><TD>Item 6</TD></TR><TR><TD>91272</TD><TD>1/11/2022</TD><TD>2/16/2022</TD><TD>Item 1</TD></TR><TR><TD>91619</TD><TD>1/12/2022</TD><TD>1/20/2022</TD><TD>Item 6</TD></TR><TR><TD>91373</TD><TD>1/12/2022</TD><TD>1/21/2022</TD><TD>Item 11</TD></TR><TR><TD>91580</TD><TD>1/12/2022</TD><TD>2/4/2022</TD><TD>Item 7</TD></TR><TR><TD>91759</TD><TD>1/12/2022</TD><TD>2/10/2022</TD><TD>Item 11</TD></TR><TR><TD>91310</TD><TD>1/12/2022</TD><TD>2/12/2022</TD><TD>Item 12</TD></TR><TR><TD>91583</TD><TD>1/12/2022</TD><TD>2/13/2022</TD><TD>Item 8</TD></TR><TR><TD>92353</TD><TD>1/13/2022</TD><TD>1/16/2022</TD><TD>Item 2</TD></TR><TR><TD>92170</TD><TD>1/13/2022</TD><TD>1/17/2022</TD><TD>Item 4</TD></TR><TR><TD>92290</TD><TD>1/13/2022</TD><TD>1/22/2022</TD><TD>Item 15</TD></TR><TR><TD>92351</TD><TD>1/13/2022</TD><TD>1/29/2022</TD><TD>Item 2</TD></TR><TR><TD>91861</TD><TD>1/13/2022</TD><TD>2/11/2022</TD><TD>Item 3</TD></TR><TR><TD>91993</TD><TD>1/13/2022</TD><TD>2/14/2022</TD><TD>Item 3</TD></TR><TR><TD>92203</TD><TD>1/13/2022</TD><TD>2/15/2022</TD><TD>Item 16</TD></TR><TR><TD>92363</TD><TD>1/14/2022</TD><TD>1/23/2022</TD><TD>Item 17</TD></TR></TBODY></TABLE>Sat, 25 Jun 2022 20:17:04 GMThttps://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601840#M75218BooRadley2022-06-25T20:17:04ZRe: DAX Measure to count if two date conditions are met
https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601849#M75220
<P>Hi BooRadley,</P><P>Please, explain how, with the inout data you provided, you count 8 open inoices at the end of January 6th.</P><P> </P><P>Best regards.</P><P> </P>Sat, 25 Jun 2022 21:16:01 GMThttps://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601849#M75220ManguilibeKAO2022-06-25T21:16:01ZRe: DAX Measure to count if two date conditions are met
https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601860#M75223
<P>So at the end of the 6th, 10 invoices have been opened but 2 have been closed. Invoice 8892 closed on the 5th and invoice 89341 closed on the 6th. </P><P> </P><P>I hope that clarifies what I meant. </P><P> </P><TABLE><TBODY><TR><TD>InvoiceNumber </TD><TD> Invoice Created On</TD><TD>Invoice Closure date</TD><TD>Material description</TD></TR><TR><TD>88912</TD><TD>1/4/2022</TD><TD>1/5/2022</TD><TD>Item 3</TD></TR><TR><TD>89025</TD><TD>1/4/2022</TD><TD>1/13/2022</TD><TD>Item 14</TD></TR><TR><TD>88792</TD><TD>1/4/2022</TD><TD>1/14/2022</TD><TD>Item 17</TD></TR><TR><TD>88767</TD><TD>1/4/2022</TD><TD>1/28/2022</TD><TD>Item 4</TD></TR><TR><TD>89201</TD><TD>1/5/2022</TD><TD>1/18/2022</TD><TD>Item 11</TD></TR><TR><TD>89341</TD><TD>1/5/2022</TD><TD>1/6/2022</TD><TD>Item 17</TD></TR><TR><TD>89487</TD><TD>1/5/2022</TD><TD>1/31/2022</TD><TD>Item 5</TD></TR><TR><TD>89399</TD><TD>1/5/2022</TD><TD>2/1/2022</TD><TD>Item 11</TD></TR><TR><TD>89694</TD><TD>1/6/2022</TD><TD>1/19/2022</TD><TD>Item 11</TD></TR><TR><TD>89689</TD><TD>1/6/2022</TD><TD>2/2/2022</TD><TD>Item 9</TD></TR></TBODY></TABLE>Sat, 25 Jun 2022 21:34:59 GMThttps://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601860#M75223BooRadley2022-06-25T21:34:59ZRe: DAX Measure to count if two date conditions are met
https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601893#M75224
<P>Calendar table needs to have an inactive relationship in order to work:</P><DIV><DIV><SPAN>#Active = </SPAN></DIV><DIV><SPAN>VAR</SPAN> <SPAN>_Active</SPAN><SPAN> = </SPAN><SPAN>MAX</SPAN><SPAN> ( </SPAN><SPAN>'Calendar'[Date]</SPAN><SPAN> )</SPAN></DIV><DIV><SPAN>RETURN</SPAN></DIV><DIV><SPAN>SUMX</SPAN><SPAN> (</SPAN></DIV><DIV><SPAN>Sheet1</SPAN><SPAN>,</SPAN></DIV><DIV><SPAN>IF</SPAN><SPAN> (</SPAN></DIV><DIV><SPAN>Sheet1[Invoice Created On]</SPAN><SPAN> <= </SPAN><SPAN>_Active</SPAN></DIV><DIV><SPAN>&& ( </SPAN><SPAN>Sheet1[Invoice Closure Date]</SPAN><SPAN> > </SPAN><SPAN>_Active</SPAN><SPAN> ),</SPAN></DIV><DIV><SPAN>1</SPAN><SPAN>,</SPAN></DIV><DIV><SPAN>0</SPAN></DIV><DIV><SPAN>)</SPAN></DIV><DIV><SPAN>)</SPAN></DIV></DIV>Sat, 25 Jun 2022 23:56:38 GMThttps://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2601893#M75224kitgo22022-06-25T23:56:38ZRe: DAX Measure to count if two date conditions are met
https://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2604363#M75368
<P>Thank you, the key thing I was struggling with making the date relationship as inactive from active. For some reason, I was hung up on thinking that it was required to have the open date as a active relationship. I very much appreciate the help you have provided and how quickly you responded.</P>Mon, 27 Jun 2022 14:19:25 GMThttps://community.powerbi.com/t5/DAX-Commands-and-Tips/DAX-Measure-to-count-if-two-date-conditions-are-met/m-p/2604363#M75368BooRadley2022-06-27T14:19:25Z