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
Anonymous
Not applicable

Need to have distinct count of two measures

Hi All,

 

I created two measures in the attached sheet which is as below for an Inflow/outflow report:

 

Inflow =
VAR d =
MAX ( 'Date'[YearMonthShort] )
RETURN
CALCULATE(DISTINCTCOUNT('Page 1'[Number]), 'Page 1'[MonthYearOpened]=d)

 

Outflow =
VAR d =
MAX ( 'Date'[YearMonthShort] )
RETURN
CALCULATE(DISTINCTCOUNT('Page 1'[Number]), 'Page 1'[MonthYearClosed]=d)

 

Where I have used the below formulae to format both the Opened and Closed date to MMMM YYYY format as it facilitated me to create an Inflow/Outflow based on monthly basis.

 

MonthYearClosed = FORMAT([Closed],"YYYY mmmm")
MonthYearOpened = FORMAT([Opened],"YYYY mmmm")

 

Everything is working as it should until this point where I wanted to create a line which should contain the distinct count of ticket numbers between Inflow & Outflow on top of the attached chart where I am stuck now (Line and Clustered Column Chart).

 

Please help!

 

Link to PBIX & Data file: https://1drv.ms/u/s!An1nJ6oXziI6hKJYHWwoKZHUW8QnOg?e=CrIyAh

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Anonymous  Sample test data will always be helpful.. but based on your description, hope I've understood correctly... Add a new measure to have count of both Inflow and Outflow as below. Let me know how it goes....

 

Total = CALCULATE(DISTINCTCOUNT('Page 1'[Number]), FILTER(ALL('Page 1'),[MonthYearClosed]=d OR [MonthYearOpened]=d))

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

4 REPLIES 4
PattemManohar
Community Champion
Community Champion

@Anonymous  Sample test data will always be helpful.. but based on your description, hope I've understood correctly... Add a new measure to have count of both Inflow and Outflow as below. Let me know how it goes....

 

Total = CALCULATE(DISTINCTCOUNT('Page 1'[Number]), FILTER(ALL('Page 1'),[MonthYearClosed]=d OR [MonthYearOpened]=d))

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

It worked like awesome!

 

Thanks a ton...

 

However I am keeping it open before accepting it as a solution a I would like other inputs as well to gain some potential knowledge out of this.

 

Below is the final formula that made it work:

 

Total =
VAR d =
MAX ( 'Date'[YearMonthShort] )
RETURN
CALCULATE(DISTINCTCOUNT('Page 1'[Number]), FILTER(ALL('Page 1'),[MonthYearClosed]=d || [MonthYearOpened]=d))
 
OR function was not taken in to DAX so I used "||" instead.
 
Once again thanks a ton and I was breaking my head for a whole day for this... I need to check the functions in Power BI and need to gain some knowledge on it!
sokg
Solution Supplier
Solution Supplier

Can you give a sample of your expected solution/result?
I did not follow your explanations.

Cheers!

Omega
Impactful Individual
Impactful Individual

Can you share sample data and image of your chart? 

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.