Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello-
I am tryint to count the # of events by comparing two calculated measures and returning the count of only those rows that meet the condition. I've been trying via the DAX statement and creation of a virtual tabkle from a much larger SQL table. The below expression appears to ignore the results of the comparision and return all rows of the virtual table.
When i substitute the COUNTAX operator with a SUMX on the same calculated column (w/o the comparison) the statement returns the correct value. Any suggestions would be greatly appreciated.
Event_Over_Budget_Count = CALCULATE(
COUNTAX(
SUMMARIZE(
table_A, table_A[eventName],
"Spend Ratio", DIVIDE
CALCULATE(
SUM (table_A[eventspend]), DATESINPERIOD(table_A[date], MAX(table_A[date]), -1, day)),
DIVIDE( MAX( table_A[budgetamt]), DATEDIFF(MIN(table_A[eventStartDate]), MAX(table_A[event[EndDate]), DAY) + 1))),
([Spend Ratio] >1 )), lookup_Table[event_active_flag] = "Y")
Solved! Go to Solution.
That worked with the help of an if statement in my virtual column to create the boolean output to sum.
Thanks!
COUNTX won't work with boolean condition. Boolean condition will return either one or zero and CONTX will count booth.
As you've already mentioned in your post, SUMX will provide perfecr count of "1".
Thanks for the quick response. Do you have any suggestions on how to count the number of rows of the virtual table that meet the conditions specified? I don't want the sum of the values from the expression i want to be able to compare each value to a criteria (in this case '1') and return a count of only those rows that meet the requirement. Do you know of a better strategy?
Thanks,
Sean
Just replace CONTX with SUMX to cout the trure condition. Boolean condition can be summed. The sum would be the count of true cases as true is translated to 1.
That worked with the help of an if statement in my virtual column to create the boolean output to sum.
Thanks!
If you find my reply helpful you may consider selecting it as acceptable solution. Thank you and have a great weekend!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
10 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
13 | |
12 | |
11 | |
8 |