Reputation: 892
I am new with powerbi. I would like to count how many column that has X value.
then do calculation.
The condition is calculate the column from PC
to RPOS
with contain of X
value. Then, calculate the FINAL
table with this condition: if the RESULT table has X
value, then the total column * 10
, if the RESULT
table does not has X
value, then the total column * 5
anyone can give me idea please. I really appreciated it. Thank you.
Here what I tried, I tried create a new column, then calculate the total column, I used the new column to get the FINAL table calculation, but it return this error
A circular dependency was detected
Here is the DAX: This is the calculation of the column
TotalColumn = CALCULATE(COUNT('Data'[PC]) + COUNT('Data'[NB]) + COUNT('Data'[DT]) + COUNT('Data'[OAI]) + COUNT('Data'[RPOS]))
This is the calculation of tabel FINAL
FINAL =
SWITCH(
TRUE()
,'Data'[Result]="X",[TotalColumn] * 100
,[TotalColumn] / 4 * 100
)
Upvotes: 0
Views: 645
Reputation: 2103
Try the measure with CALCULATE like this:
TotalColumn =
VAR PC = 'Data'[PC]
VAR NB = 'Data'[NB]
VAR DT = 'Data'[DT]
VAR OAI = 'Data'[OAI]
VAR RPOS = 'Data'[RPOS]
VAR Result = 'Data'[RESULT]
RETURN
CALCULATE(
COUNT('Data'[PC]) + COUNT('Data'[NB]) + COUNT('Data'[DT])
+ COUNT('Data'[OAI]) + COUNT('Data'[RPOS])
,'Data'[PC]=PC
,'Data'[NB]=NB
,'Data'[DT]=DT
,'Data'[OAI]=OAI
,'Data'[RPOS]=RPOS
,'Data'[RESULT]=Result
,ALL()
)
ALL() works first (due to DAX priorities) and removes all filters, then reapply all Filters with Values
Upvotes: 1