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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vivek_rana
Frequent Visitor

ID Count For Current Month and Carry forward NULL values to next Month.(and more conditions)

Hi  Power BI Community ,

 

I need support. Will appreciate the help.

 

I have 2 Date Columns , Open Date and Close Date.

 

Open Date                  Close Date                ID
1/1/2021                                                      A
1/1/2021                     1/1/2021                  B
2/1/2021                     2/15/2021                C
2/1/2021                     2/20/2021                D
2/1/2021                     7/31/2021                E
3/1/2021                     3/1/2021                  F

 

Users will have Date filter to choose Open and Close Date. (Do we create Calender Table Here?)

Based on the user selection ---- a period is Decided.

Lets Say user selected :
Start Date - 1/1/2021
End Date - 3/31/2021


Desired Output should be  this:

Month               First_Date_of_The_period                     Last_Day_Of_the_Period                              Count_of_ID
Jan                    1/1/2021                                               1/31/2021                                                           2
Feb                    2/1/2021                                               2/28/2021                                                          4
Mar                   3/1/2021                                               3/31/2021                                                           3

 

Challenge is to find the count of ID's Based on conditions:-

1.     IF Closedate is null   (in our case  - for id A) or

        greater than Last_Day_of_a_period. ( in our case for id F) , 

        then ID_count must add to next month ID count.

So,
For Jan we have 2 IDs , so ID count is 2.
For Feb we have 3 ID , but one null ID. So it should be added  to Feb count. So  count for feb should be 4.
And for March we have one null coming from Feb + 1 ID from March + One ID From Feb (id F ) as it is greater than 3 month period that user selected.

 

please find link for  excel file , with output working perfectly fine, but unable to do it power bi.

Please find Formulae in Column O.

https://drive.google.com/drive/folders/1ZarwBRxga1lyPcJiqVW-iFe44jfHoD0o?usp=sharing

 

ThankYou

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @vivek_rana 

"And for March we have one null coming from Feb + 1 ID from March + One ID From Feb (id F ) as it is greater than 3 month period that user selected."

Not sure how 3 comes, could you add more details?

 

I also create a sample to calculate the count, however, it seems the count_of_ID is 5 in March.

vxiaotang_0-1635489698024.png

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @vivek_rana 

 

First, you need a Date table, there are many ways. see this link:

https://www.vahiddm.com/post/creating-calendar-table-with-3-steps

 

then you can create another table, and use that to cover this request:

 

New Table =
FILTER (
ALL ( table ),
Table[Open Date] >= MIN ( DateTable[Date] )
&& Table[Close Date] >= MAX ( DateTable[Date] )
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.