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.
Hi there,
Here is some demo data to describe my issue:
What I want to do, is for any given date range show the percentage of a Vendor's applications that have at least one Error in the Log table for the specified date range. In other words, if my date range were to cover all of January 2019 then the result would be:
Infosoft 50%
Pearsoft 0%
This is because there are two ERROR entries for "Spreadshet 500" in January, so that application does have errors, but no entries for "Mail Client 500", therefore 50% of Infosoft's applications in that time period have one or more errors.
If however the filter was changed to just January 1st then the result would be:
Infosoft 0%
Pearsoft 0%
This is because none of the applications logged errors on the 1st January.
Many thanks in advance.
Solved! Go to Solution.
@Anonymous
If I assume your tables are named Log, Application and Vendor, you could write a measure like this:
Application % with at least one error = VAR ApplicationCount = COUNTROWS ( Applications ) VAR ApplicationCountWithError = IF ( ApplicationCount, // Add zero to ensure 0% is returned rather than blank in cases with no ERRORs CALCULATE ( DISTINCTCOUNT ( 'Log'[ApplicationId] ), 'Log'[EntryType] = "ERROR" ) + 0 ) RETURN DIVIDE ( ApplicationCountWithError, ApplicationCount )
This worked for me in a dummy model - does it work in your model?
Regards,
Owen
@Anonymous
If I assume your tables are named Log, Application and Vendor, you could write a measure like this:
Application % with at least one error = VAR ApplicationCount = COUNTROWS ( Applications ) VAR ApplicationCountWithError = IF ( ApplicationCount, // Add zero to ensure 0% is returned rather than blank in cases with no ERRORs CALCULATE ( DISTINCTCOUNT ( 'Log'[ApplicationId] ), 'Log'[EntryType] = "ERROR" ) + 0 ) RETURN DIVIDE ( ApplicationCountWithError, ApplicationCount )
This worked for me in a dummy model - does it work in your model?
Regards,
Owen
That works perfectly! Thank you so much, I really was fumbling around in the dark on this as I am completely new to Power BI. I didn't realize that measures can be written in the form of functions.
Could you just explain why you use the IF clause and how the condition evaluates. I assume ApplicationCount is an integer value so when you just state:
IF(ApplicationCount, ...
Does this mean "if ApplicationCount is not null" or "if ApplicationCount != 0"?
And what happens if the condition is false, since there is no third IF parameter specified? Does it make ApplicationCountWithError zero or null?
Can you also recommend a good book on DAX that would get me to this type of level?
Thank you again.
That's good to hear 🙂
It looks like all of your assumptions are correct 🙂
Some books on DAX...I would recommend:
To get started:
More advanced:
Regards,
Owen
Thank you for explanation on the IF clause, and also thank you for the book recommendations. I have purchased the Power Pivot Pro book for the starter book, and both the advanced ones you recommended.
Many thanks once again!
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 |
---|---|
114 | |
100 | |
81 | |
70 | |
62 |
User | Count |
---|---|
148 | |
116 | |
104 | |
90 | |
65 |