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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Super User
Super User

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.

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.