Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Total Distinctcount on aggregate value

Hi there,
I have been researching everywhere but I cannot find the same answer.


Raw data: I have a table where the agent received a score based each Date.

DateAgentNameScore
1/05/2022Kim10
2/05/2022Jane50
3/05/2022Kim20
4/05/2022Annie5
5/05/2022Tom6
6/05/2022Joe25
7/05/2022Tom40


Visualisation 1: I sum the total score each agent received. I also add the [Date] as slicer.
PLUS I added a measure - if the score < 25 then 1 else 0

AgentNameSum of ScorePass/Fail
Annie51
Jane500
Joe251
Kim300
Tom460


Now, what I want is to Distinctcount [AgentName] who received 1, subject to the [Date] filter in slicer.
Eg. without filter , I want to get a value of 2 (Discountcount on AgentName). Or if I want to filter [Date} between 06/05/2022 and 07/05/2022, I should get a value of 1.

Here is the formula I got stuck with :'(
Var StartDate = MIN(Table[Date])
Var EndDate = MAX(Table[Date])
Var RelativeValue = SWITCH(ISFILTERED(Table[Date]),
TRUE, CALCULATE(SUM([Score]), AND(Table[Date] >= StartDate, Table[Date] <= EndDate), FILTER(Table, [Score] <25)),
FALSE, CALCULATE(SUM([Score]), FILTER(Table, [Score] <25)))

RETURN
IF(RelativeValue = BLANK(), 0, RelativeValue)


1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
You can use

Pass/Fail = 
SUMX ( 
    SUMMARIZE ( 'Table', 'Table'[AgentName],'Table'[Date] ),
    CALCULATE (
        IF ( [Sum of Scores] > 25, 1 )
    )
)

1.png

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 
You can use

Pass/Fail = 
SUMX ( 
    SUMMARIZE ( 'Table', 'Table'[AgentName],'Table'[Date] ),
    CALCULATE (
        IF ( [Sum of Scores] > 25, 1 )
    )
)

1.png

Whitewater100
Solution Sage
Solution Sage

Hi:

You can try two calculated columns and one measure. Measure at bottom.

CC#1.
Total Score = CALCULATE(SUM('Table'[Score]), ALLEXCEPT('Table','Table'[AgentName]))
CC#2
Score < 25 = IF('Table'[Total Score] <= 25, 1,0)
Whitewater100_0-1653316407403.png
Score Count = CALCULATE(DISTINCTCOUNT('Table'[AgentName]),'Table'[Score < 25] = 1)
I hope this helps!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.