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

Summarise DAX

Hi All

 

I would like to count the number of unique projects I have with revenue and was wondering if I should use the summarise function?

 

DATA.jpg

I was considering using DistinctCount but I believe it's done on a row-by-row basis which should give an answer of 3 but project A shouldn't be counted anymore as the revenue cancels out to 0 after march.

 

Thanks!

 

1 ACCEPTED SOLUTION

Hi,

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
v-zhenbw-msft
Community Support
Community Support

Hi @swongbg ,

 

We can create a calculate column and a measure to meet your requirement.

 

1. First you need to have a date column like this,

 

Sum 1.jpg

 

2. Then we can create a secondary column to calculate the accumulate of revenue.

 

Column = CALCULATE(SUM('Table'[Revenue]),FILTER(ALLSELECTED('Table'),'Table'[Date]<=EARLIER('Table'[Date])&& 'Table'[ProjectID]=EARLIER('Table'[ProjectID])))

 

Sum 2.jpg

 

3. At last we can create a measure to calculate the distinct count of Project ID.

 

Count ID = CALCULATE(DISTINCTCOUNT('Table'[ProjectID]),FILTER('Table','Table'[Column]>0))

 

Sum3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

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

many thanks @v-zhenbw-msft 

 

For YTD march, the count should be 2 - project B have revenue of $35 and project C have revenue of $50 (just no transaction in March)

 

Thanks!

 

Hi,

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

@swongbg , Try like

countx(filter(summarize(Table,Table[project],"_1",Sum(Table[revenue])),[_1]>0),[project])

Can I use this formula directly? It says the expression is not valid or appears to be incomplete...

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.