Forum Discussion
Calculations using DAX
Hi guys,
I am having a table with 18k+ rows, but it is only 715 unique (DISTINCT) ID's, which means only 715 unique documents with different ID's. I am trying to get the "Extracted" values, which means values that are not blank or empty, and also to get the Blanks from this table based on the field and to visuals into a chart. So far I have:
My DAX measures are:
CountBlanks:
Extracted:
My issue appears as it can be seen from the visual above that let's say for Amount field I am Extracting 4k and I have 1,6k Blanks (which returns everything from the table without having in mind that the Row should be DISTINCT on DocId).
How can I achieve the same result, but just return the result based on Distinct DOCID, that it would take the output based on 715 documents (Distinct) and not based on 18k Docs (not distinct)? So the end result should be maximum Extracted or Blank 715 or in between this number.
Thanks!
Matas
Matas
Please tryExtracted = VAR T1 = VALUES ( TableName[DOCID] ) VAR T2 = ADDCOLUMNS ( T1, "@NumOfBlanks", SUMX ( CALCULATETABLE ( TableName ), IF ( TableName[Value] = BLANK (), 1 ) ) ) VAR T3 = FILTER ( T2, [@NumOfBlanks] = BLANK () ) RETURN COUNTROWS ( T3 )Blanks = VAR T1 = VALUES ( TableName[DOCID] ) VAR T2 = ADDCOLUMNS ( T1, "@NumOfBlanks", SUMX ( CALCULATETABLE ( TableName ), IF ( TableName[Value] = BLANK (), 1 ) ) ) VAR T3 = FILTER ( T2, [@NumOfBlanks] <> BLANK () ) RETURN COUNTROWS ( T3 )
13 Replies
- tamerj1Community Champion
Matas
Please tryExtracted = VAR T1 = VALUES ( TableName[DOCID] ) VAR T2 = ADDCOLUMNS ( T1, "@NumOfBlanks", SUMX ( CALCULATETABLE ( TableName ), IF ( TableName[Value] = BLANK (), 1 ) ) ) VAR T3 = FILTER ( T2, [@NumOfBlanks] = BLANK () ) RETURN COUNTROWS ( T3 )Blanks = VAR T1 = VALUES ( TableName[DOCID] ) VAR T2 = ADDCOLUMNS ( T1, "@NumOfBlanks", SUMX ( CALCULATETABLE ( TableName ), IF ( TableName[Value] = BLANK (), 1 ) ) ) VAR T3 = FILTER ( T2, [@NumOfBlanks] <> BLANK () ) RETURN COUNTROWS ( T3 )- MatasAdvocate II
tamerj1 just thinking if I can apply the same login here?
basically I am calculating the Extracted if the Call_Point = "EX02" and Value column is not Blank.
Validated is the same, Call_Point = "VA02" and Value column is not Blank.Do you think I can apply the same logic? Or I need a way different approach? If you may answer to this one too, would be great!
Regards,
Matas
- MatasAdvocate II
Hi tamerj1
Thank you for reply. My end goal is to show the Extracted and Blank values based on number of Distinct ID's categorized into separate fields.
Extracted means that my Column "VALUE" has any value, as long it is not null or Blank.
Blank, well it literally means Blank inside of "VALUE" column.
The solution should be that somehow I should calculate the Extracted and Blanks based on Distinct ID. Since my total number of distinct ID's is 715 documents, this graph maximum point should be 715. But depending on the Extracted and Blanks, it can be let's say 658 Extracted and 57 Blanks or so.
Hopefully I have not confused you even more.
Regards,
Matas