Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi, I'm new using Power Bi. I'm having a problem counting the values in a column.
In my case I want to get the count of the total occurrences of a value in a column, but I can't get the correct number
In a table I have the Effector and Prescriber fields. I want to count the total number of times an effector is itself a prescriber, regardless of whether the effector and prescriber coincide.
Example: In the following table visualization I select the effecter as the column. In the case that I analyze Amato Alicia tells me that when I do the prescriber count is 10. However when in the table filter by prescriber amato alice appears 12 times in the table. In excel with a CONTAR.SI works by referencing the cell over which you want to get the total =CONTAR.SI("ATORANGED";" CELL WITH VALUE"). I try to solve it using view and a count of values, with DAX functions like CALCULTA AND COUNT and obviously something I'm not doing right.
Solved! Go to Solution.
In addition to Greg_Deckler 's reply, try this measure.
Medida =
IF (
HASONEVALUE ( Hoja1[Efector] ),
COUNTROWS (
FILTER ( ALL ( Hoja1 ), Hoja1[Prescriptor] = MAX ( Hoja1[Efector] ) )
) + 0,
COUNTROWS ( ALLSELECTED ( Hoja1 ) )
)
Result is as below.
Here we use all in countrows is to calculate in whole table in each Efector, or it will just count in current row. Max in measure is to get the current value in text format. You see here Medida measure will return a correct result.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
It's weird, I don't have any filters applied. What I see is that it seems that logic tells me the number of times that effector and prescriber coincide and I want it to bring me the total number of times that the prescriber appears in the table.
@Syndicate_Admin So, you would need to construct a measure like:
Measure =
VAR __Efector = MAX('Table'[Efector])
RETURN
COUNTROWS(FILTER(ALL('Table'),[Prescriptor] = __Efector))
"Prescripciones: =
var CONTEO=CALCULATE(COUNT('CrudosDev Ambulatorio'[Prescriptor]))
var PRESC='CrudosDev Ambulatorio'[Prescriptor]
RETURN
SUMX(FILTER('CrudosDev Ambulatorio','CrudosDev Ambulatorio'[Prescriptor]=PRESC),CONTEO)"
In addition to Greg_Deckler 's reply, try this measure.
Medida =
IF (
HASONEVALUE ( Hoja1[Efector] ),
COUNTROWS (
FILTER ( ALL ( Hoja1 ), Hoja1[Prescriptor] = MAX ( Hoja1[Efector] ) )
) + 0,
COUNTROWS ( ALLSELECTED ( Hoja1 ) )
)
Result is as below.
Here we use all in countrows is to calculate in whole table in each Efector, or it will just count in current row. Max in measure is to get the current value in text format. You see here Medida measure will return a correct result.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you a lot Thanks @Syndicate_Admin try to understand what the measure does but I get lost, you can explain it to me so I can understand the logic?
Thank you!
@Syndicate_AdminI'll give you a smaller example of what I want to achieve. In the excel what I want to get, in the pbix what returns me
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |