Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
seira88
Frequent Visitor

Considering Records within Opened and Closed dates

Hi, 

 

Need suggestions on how to resolve the logic issue I have right now. 

Expected Outcome:

Data:    
IDDate OpenedDate Closed  
1Jul-17   
2Jul-17Aug-17  
3Aug-17Aug-17  
4Sep-17   
5Oct-17Oct-17  
     
 Jul-17Aug-17Sep-17Oct-17
NEW2111
OPEN2122
NFA 1 1

 

Logic:
Data is counted as New if it is opened within the month
Data is counted as Open if it is not closed within the month (data opened on a different month is counted as well)
Data is counted as NFA if it is closed within the month

 

Current Power BI Behaviour:

 Jul-17Aug-17Sep-17Oct-17
NEW2111
OPEN1122
NFA 1 1

 

Analysis: Power BI doesn't consider/count data with Closed Date as Open.

 

Data:
I have Data Table (Table1) and a Date Table (New Table created in Power BI).

Logic in counting Open Data -

New Column:
IsOpen = IF(ISBLANK('Table1'[closeddate]) &&
'Table1'[OpenedClosed_SameMonth] <> 1, 1,0)

New Quick Measure (Running Total):
OPEN =
CALCULATE(
SUM('Table1'[IsOpen]),
FILTER(
CALCULATETABLE(
SUMMARIZE('Date', 'Date'[MonthYearInt], 'Date'[MonthYear]),
ALLSELECTED('Date')
),
ISONORAFTER(
'Date'[MonthYearInt], MAX('Date'[MonthYearInt]), DESC,
'Date'[MonthYear], MAX('Date'[MonthYear]), DESC
)
)
)

 

Thank you in advance!

1 ACCEPTED SOLUTION

Hi,

 

Here's the result i got.  You may download my PBI file from here.  Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
ImkeF
Community Champion
Community Champion

Maybe using OR instead of AND in the condtion would work:

 

old:

IsOpen = IF(ISBLANK('Table1'[closeddate]) &&
'Table1'[OpenedClosed_SameMonth] <> 1, 1,0)

 

new:

IsOpen = IF(ISBLANK('Table1'[closeddate]) ||
'Table1'[OpenedClosed_SameMonth] <> 1, 1,0)

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

seira88
Frequent Visitor

Hi, I tried "||" but it gives me this result.

 

 Jul-17Aug-17Sep-17Oct-17
NEW2111
OPEN2355
NFA 1 1

 

the succeeding month mismatch with the expected output.

Anonymous
Not applicable

@seira88,

What field of table1 do you use to create relationship between table1 and date table? Do you get expected result when you directly drag isOpen column to your visual?

Also please share us your Date table.

Regards,
Lydia

Hi Lydia,

 

I created DateAsInt field in both Table1 and Date tables and that is what I used to link them. 

As per IsOpen, I cannot directly use it as I won't see the  value of previous months wherein thereis no data created. (see example below)

Data:  
IDDate OpenedDate Closed
1Jul-17 
2Jul-17Aug-17
3Aug-17Aug-17
4Oct-17 
5Nov-17Nov-17

 

Expected Outcome:

 Jul-17Aug-17Sep-17Oct-17Nov-17
NEW21011
OPEN21122
NFA 10 1

 

Power BI Result:

 Jul-17Aug-17Sep-17Oct-17Nov-17
NEW21 11
OPEN11 022
NFA 1  1

 

Hope this answered your clarifications. Thanks!

Hi,

 

Here's the result i got.  You may download my PBI file from here.  Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors