cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
pintobean87
Frequent Visitor

Create columns that count number of blanks and populated cells

So I have two columns: "Start date" and "End date" Some cells in the columns, however, are blank. So, I want to create 3 columns that add a "1" in the their respective cells based on the following conditions:

 

Column One: If row has a start date and end date, then add a "1"

Column Two: If row has a start date and no end date, then add a "1"

Column Three: If row has no start date and no end date, then add a "1"

 

Reason I want three columns is because then I'll add up those 1s to display the number of rows that fall under each category.

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @pintobean87 

 

Download example PBIX file

 

You can do this with measures.  Usually best to use measures when you can rather than create unnecessary columns in your data set.

 

 

Start Date and End Date = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', NOT ISBLANK('DataTable'[End Date]) && NOT ISBLANK('DataTable'[Start Date])))

 

 

 

No End Date = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', ISBLANK('DataTable'[End Date]) && NOT ISBLANK('DataTable'[Start Date])))

 

 

 

No Start Date and No End Date = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', ISBLANK('DataTable'[End Date]) && ISBLANK('DataTable'[Start Date])))

 

 

enddates.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @pintobean87,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
FreemanZ
Super User
Super User

Try add three columns with the codes respectively:
Column One = IF ([Start Date]<>BLANK()&&[End Date]<>BLANK(),1)
Column Two = IF ([Start Date]<>BLANK()&&[End Date]=BLANK(),1)
Column Three = IF ([Start Date]=BLANK()&&[End Date]=BLANK(),1)
 
If you feel comfortable with Power Query, you shall turn to PQ to add conditional columns.
PhilipTreacy
Super User
Super User

Hi @pintobean87 

 

Download example PBIX file

 

You can do this with measures.  Usually best to use measures when you can rather than create unnecessary columns in your data set.

 

 

Start Date and End Date = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', NOT ISBLANK('DataTable'[End Date]) && NOT ISBLANK('DataTable'[Start Date])))

 

 

 

No End Date = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', ISBLANK('DataTable'[End Date]) && NOT ISBLANK('DataTable'[Start Date])))

 

 

 

No Start Date and No End Date = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', ISBLANK('DataTable'[End Date]) && ISBLANK('DataTable'[Start Date])))

 

 

enddates.png

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors