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
jbrolland
Frequent Visitor

Improper calculation for non closed items within a month

 

current behavior

I feel like I am overcomplicating my table but here is the graph I am generating today

 

jbrolland_0-1623223247451.png

 

 

However the Open Vs Closed (orange) is not correct for 2021-06.

It should be 17 (75-58) instead of 14.

Here is my table

STATUS OF THE ACTION PLANOpen DateClosed DateOpened Year and MonthClosed Year and MonthOpened by MonthClosed by MonthOpen or CloseOpened Vs Closed
DONE18-Jan-2112-Feb-212021-012021-0221152021-026
ONGOING12-Jan-21 2021-01Not closed2102021-010
DONE12-Jan-2112-Feb-212021-012021-0221152021-026
DONE12-Jan-2129-Jan-212021-012021-012142021-0117
DONE12-Jan-2105-Mar-212021-012021-0321322021-03-11
ONGOING12-Jan-21 2021-01Not closed2102021-010
DONE12-Jan-2123-Apr-212021-012021-0421482021-04-27
DONE12-Jan-2126-Feb-212021-012021-0221152021-026
DONE12-Jan-2105-Mar-212021-012021-0321322021-03-11
DONE21-Jan-2129-Jan-212021-012021-012142021-0117
DONE12-Jan-2105-Feb-212021-012021-0221152021-026
ONGOING21-Jan-21 2021-01Not closed2102021-010
DONE25-Jan-2105-Feb-212021-012021-0221152021-026
DONE28-Jan-2129-Jan-212021-012021-012142021-0117
DONE20-Jan-2126-Feb-212021-012021-0221152021-026
DONE15-Jan-2112-Feb-212021-012021-0221152021-026
DONE12-Jan-2129-Jan-212021-012021-012142021-0117
DONE29-Jan-2117-Feb-212021-012021-0221152021-026
ONGOING19-Jan-21 2021-01Not closed2102021-010
DONE29-Jan-2118-Mar-212021-012021-0321322021-03-11
DONE29-Jan-2122-Mar-212021-012021-0321322021-03-11
DONE22-Feb-2119-Mar-212021-022021-0339322021-037

....... cannot put the whole table unfortunately, here is the end to understand what is going on

STATUS OF THE ACTION PLANOpen DateClosed DateOpened Year and MonthClosed Year and MonthOpened by MonthClosed by MonthOpen or CloseOpened Vs Closed
DONE30-Apr-2130-Apr-212021-042021-0466482021-0418
DONE21-Apr-2122-Apr-212021-042021-0466482021-0418
ONGOING26-May-21 2021-05Not closed7202021-050
DONE12-May-2121-May-212021-052021-0572552021-0517
DONE13-May-2128-May-212021-052021-0572552021-0517
ONGOING17-May-21 2021-05Not closed7202021-050
ONGOING06-May-21 2021-05Not closed7202021-050
DONE28-May-2104-Jun-212021-052021-0672582021-0614
ONGOING01-Jun-21 2021-06Not closed7502021-060
ONGOING02-Jun-21 2021-06Not closed7502021-060
ONGOING03-Jun-21 2021-06Not closed7502021-060

 

 

The first 3 columns are not computed, the rest is and here are the formula per column

 
Opened Year and Month = FORMAT(DATE(YEAR([Open Date]),MONTH([Open Date]),1),"YYYY-MM")
Closed Year and Month = IF(ISBLANK('Incidents follow-up with Paris'[Closed Date]), "Not closed", FORMAT(DATE(YEAR([Closed Date]),MONTH([Closed Date]),1),"YYYY-MM"))
Opened by Month = 
CALCULATE (
Count('Incidents follow-up with Paris'[Opened Year and Month]),
ALL('Incidents follow-up with Paris'),
'Incidents follow-up with Paris'[Opened Year and Month] <= EARLIER ( 'Incidents follow-up with Paris'[Opened Year and Month] )
)
Closed by Month = 
IF ('Incidents follow-up with Paris'[Closed Year and Month] = "Not Closed", 0,(CALCULATE (
Count('Incidents follow-up with Paris'[Closed Year and Month]),
ALL ( 'Incidents follow-up with Paris'),
'Incidents follow-up with Paris'[Closed Year and Month] <= EARLIER ( 'Incidents follow-up with Paris'[Closed Year and Month])
)))
Open or Close = IF([Closed Year and Month] = "Not Closed", 'Incidents follow-up with Paris'[Opened Year and Month], 'Incidents follow-up with Paris'[Closed Year and Month])
Opened Vs Closed = if('Incidents follow-up with Paris'[Closed by Month] = 0, 0, [Opened by Month] - [Closed by Month])
 
 
My graph for Open Vs Close will take Maximum of Open Vs CLosed so it is going to take the 4th row starting from last cause there is no item closed in June yet ending up to 14.
 
jbrolland_1-1623223706239.png

 

 

expected behavior

Able to get the proper calculation either in table or in the graph for June i.e 17 (75 - 58) even if nothing is closed in June

 

 

 

Solution ( I am not able to reply to @AllisonKennedy .... so I post my reply here)

Hi

I am not familiar with measure and had to scratch my head to find the formula but thanks for your advice @AllisonKennedy , it helped me to solve it:

I added MEASURES indeed with below formula (I removed the column Opened vs Closed first)

 

Opened vs Closed = MAX('Incidents follow-up with Paris'[Opened by Month] ) - MAX('Incidents follow-up with Paris'[Closed by Month] )
 
jbrolland_0-1623298567817.png

 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@jbrolland  You may need to do these as MEASURES not columns because in your calculated table, the value for 6 June is 72 (not 75) because the Opened Year and Month is still in May... 

AllisonKennedy_0-1623229795080.png

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@jbrolland  You may need to do these as MEASURES not columns because in your calculated table, the value for 6 June is 72 (not 75) because the Opened Year and Month is still in May... 

AllisonKennedy_0-1623229795080.png

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thanks I manage to find the solution thanks to your advice, please check my initial post casue there are too many restrictions on replying for unknown reason (I guess because a copy paste it s really frustrating and time consuming).

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.