Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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!
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
19 | |
14 | |
8 | |
7 |