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
wes-shen-poal
Helper III
Helper III

Add a calculated column that count number of rows based on an existing column

Hi there,

 

I am very new to DAX, and I'm assuming this would be a very easy DAX formula that I just don't know.

I want to add a calculated column (highlight yellow) which gives me the count of VehicleIDs (or rows) based on the Ship Voyage column

 

Capture.PNG

 

 

Can someone kindly assist?

 

Thanks in advance.

Wes

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @wes-shen-poal,

 

You can create a calculated column like this:

Vehicles Onboard = CALCULATE(COUNTROWS('Table1'),FILTER('Table1','Table1'[Ship Voyage]=EARLIER(Table1[Ship Voyage])))

 

Or you can create a measure like below:

Measure = CALCULATE(COUNTROWS('Table1'),FILTER(ALL('Table1'),'Table1'[Ship Voyage]=MAX('Table1'[Ship Voyage])))

 

q1.PNG

 

You can download attached pbix file to have a look.

 

Best Regards,
Qiuyun Yu

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi there,
We hope you can help us.! 😄 

Is it possible to make a formula where the first number of two will be changed to “1” and the second one to “0” based on characteristics seen in the first row.
Example: 
"if customer name or category or customer number is mentioned several times?"

 

We have tried to create a formula. but we have not solved the problem yet, hope you understand the problem. 

Calculated column =CALCULATE(COUNT(Append1[category]);ALLEXCEPT(Append1;Append1[category];Append1[customer number];Append1[dateyear]))  

Customer numberCustomer nameCustomer CategoryCategoryDateyearCalculated Column 1
1273Peter Hansen1253568942PersonbogCPR20191
1331Anne Jensen123456789PersonbogCPR20192
1331Anne Jensen123456789PersonbogCPR20192
1349Poul West15423697PersonbogCPR20191

 

 

v-qiuyu-msft
Community Support
Community Support

Hi @wes-shen-poal,

 

You can create a calculated column like this:

Vehicles Onboard = CALCULATE(COUNTROWS('Table1'),FILTER('Table1','Table1'[Ship Voyage]=EARLIER(Table1[Ship Voyage])))

 

Or you can create a measure like below:

Measure = CALCULATE(COUNTROWS('Table1'),FILTER(ALL('Table1'),'Table1'[Ship Voyage]=MAX('Table1'[Ship Voyage])))

 

q1.PNG

 

You can download attached pbix file to have a look.

 

Best Regards,
Qiuyun Yu

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

Hi @v-qiuyu-msft

 

Thank you so much for your help.

 

Wes

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.