Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I have the following Table1:
Name | ID |
John | 111 |
John | 222 |
Jane | 333 |
Jane | 111 |
Jane | 444 |
I get the counts of the IDs for each name like below (COUNTX('Table1', [ID])):
Name | Count of ID |
John | 2 |
Jane | 3 |
I'd like to weigh the counts of any matching values in the ID column by .5. So since John and Jane both have a 111, that count is now .5, resulting in:
Name | Count of ID |
John | 1.5 |
Jane | 2.5 |
I can't figure out how to write a function for this. Appreciate any assistance!
Solved! Go to Solution.
@NAMLANI Perhaps something like this:
Measure =
VAR __Name = MAX('Table'[Name])
VAR __WeightTable = SUMMARIZE(ALL('Table'),[ID],"__Weight",1/COUNTROWS('Table'))
VAR __Table = ADDCOLUMNS('Table',"__Score",MAXX(FILTER(__WeightTable,[ID] = EARLIER('Table'[ID])),[__Weight]))
RETURN
SUMX(__Table, [__Score])
HI @NAMLANI , @Greg_Deckler - I was going to suggest the following:
New Measure =
SUMX (
ADDCOLUMNS (
'Table',
"ID Count",
VAR _ID = 'Table'[ID]
RETURN
CALCULATE (
COUNTA ( 'Table'[ID] ),
REMOVEFILTERS ( 'Table' ),
'Table'[ID] = _ID
)
),
DIVIDE ( 1, [ID Count] )
)
@NAMLANI Perhaps something like this:
Measure =
VAR __Name = MAX('Table'[Name])
VAR __WeightTable = SUMMARIZE(ALL('Table'),[ID],"__Weight",1/COUNTROWS('Table'))
VAR __Table = ADDCOLUMNS('Table',"__Score",MAXX(FILTER(__WeightTable,[ID] = EARLIER('Table'[ID])),[__Weight]))
RETURN
SUMX(__Table, [__Score])