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.
Hello
I have a simple issue:
Source table
Aggregated table:
How to get only a count for a link that has a non-null value? In this case, I should get 3: link1+link2+link4=3
Solved! Go to Solution.
try the following formula:
countdistinctnonblank = CALCULATE(DISTINCTCOUNTNOBLANK(emails[link]), emails[link]<>"" && NOT ISBLANK(emails[link]))
@themistoklis @amitchandak @Anonymous
Thanks a lot for such a quick response.
I tried all of your solutions and only @themistoklis solution gave me the correct results:
@themistoklis Do you know why I need to wrap around CALCULATE? Why just simple function DISTINCTCOUNTNOBLANK does not have correct results?
Hello @ignas
I used 'Calculate' function as I had to apply filters (e.g. <>"" && NOT IS BLANK) in the formula.
You can only apply filters in a formula through the CALCULATE function.
https://docs.microsoft.com/en-us/dax/calculate-function-dax
@themistoklis
I understand how CALCULATE function works. I just cannot understand why I cannot use only DISTINCTCOUNTNOBLANK function in this case? Why if I only use DISTINCTCOUNTNOBLANK it still gives me a value of 4 which means it still counts blanks.
It has to do with your background data. PowerBI treats differently Blank, NULL and EMPTY values.
Maybe the following 2 articles will give you the answer:
https://www.sqlbi.com/articles/blank-handling-in-dax/
try the following formula:
countdistinctnonblank = CALCULATE(DISTINCTCOUNTNOBLANK(emails[link]), emails[link]<>"" && NOT ISBLANK(emails[link]))
@ignas , Try a new measure like
calculate(distinctcount(Table[link]),not(isblank(Table[link])))
[# Distinct Non-Blank Links] =
calculate(
distinctcount( T[link] ),
keepfilters( not isblank( T[Link] ) )
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |