Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
| UID | DID | Dist_DID | Num_Dist_UID |
| U1 | D3 | 2 | 3 |
| U1 | D54 | 2 | 3 |
| U2 | D8 | 1 | 2 |
| U3 | D9 | 2 | 3 |
| U3 | D11 | 2 | 3 |
| U3 | D11 | 2 | 3 |
| U4 | D23 | 1 | 2 |
| U5 | D35 | 2 | 3 |
| U5 | D87 | 2 | 3 |
This is the "original" table:
| User ID | Device ID |
| U1 | D3 |
| U1 | D54 |
| U2 | D8 |
| U3 | D9 |
| U3 | D11 |
| U3 | D11 |
| U4 | D23 |
| U5 | D35 |
| U5 | D87 |
| User ID | Distdisps |
| U1 | 2 |
| U1 | 2 |
| U2 | 1 |
| U3 | 2 |
| U3 | 2 |
| U3 | 2 |
| U4 | 1 |
| U5 | 2 |
| U5 | 2 |
| Distdisps |
| 1 |
| 2 |
| 3 |
| 5 |
| ... |
| n |
| Distdisps | Distusrs |
| 1 | 3 |
| 2 | 2 |
| 3 | 7 |
| 5 | 1 |
| ... | |
| n | m |
Solved! Go to Solution.
Hi , @acolin
Thanks for your sample data and detailed description.
According to your description, in my thought , you want to create a measure to get the sum of [Distusrs] , like this:
If this , you can refer to :
(1)We can crecate a number as row headers:
We do not need to create any relationship between tables.
(2)You can create a measure like this:
Measure = var _t = ADDCOLUMNS('Table',"Distdisps" , CALCULATE(DISTINCTCOUNT('Table'[DID]) , 'Table'[UID]=EARLIER([UID]) ,ALL('Table'[DID])))
var _t2 = ADDCOLUMNS( _t ,"Distusrs", var _Distdisps = [Distdisps] var _test = DISTINCT(SELECTCOLUMNS( FILTER(_t ,[Distdisps]=_Distdisps),"uid" ,[UID])) return COUNTROWS(_test) )
var _cur_num = VALUES('Number'[Column1])
var _t3 = FILTER(_t2 , [Distdisps] in _cur_num)
return
SUMX(_t3 , [Distusrs])
Then we can put this measure on the visual like this , the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks for your kindness and answer! Not precisely what I wanted to do, so I changed the code a little bit and it worked for me.
var _t0 = SUMMARIZE(tblfraudesantander, tblfraudesantander[User ID], "Distdisps", CALCULATE(DISTINCTCOUNT('tblfraudesantander'[Device ID]), 'tblfraudesantander'[User ID]=EARLIER([User ID]), ALL('tblfraudesantander'[Device ID])))
var _t1 = DISTINCT(SELECTCOLUMNS(_t0, "Distdisps", [Distdisps]))
var _t2 = ADDCOLUMNS( _t1, "Distusrs",
var _Distdisps = [Distdisps]
var _test = DISTINCT(SELECTCOLUMNS(FILTER(_t0, [Distdisps]=_Distdisps), "UID", [User ID]))
return COUNTROWS(_test))
var _t3 = FILTER(_t2 , [Distdisps] in VALUES(Indice[IDX]))
RETURN
SUMX(_t3 , [Distusrs])The _t2 stage was the key part of my trouble, didn't know how create that filter for the _t0 table. Also what a nice profile pic there, nice anime series!
Hi , @acolin
Thanks for your sample data and detailed description.
According to your description, in my thought , you want to create a measure to get the sum of [Distusrs] , like this:
If this , you can refer to :
(1)We can crecate a number as row headers:
We do not need to create any relationship between tables.
(2)You can create a measure like this:
Measure = var _t = ADDCOLUMNS('Table',"Distdisps" , CALCULATE(DISTINCTCOUNT('Table'[DID]) , 'Table'[UID]=EARLIER([UID]) ,ALL('Table'[DID])))
var _t2 = ADDCOLUMNS( _t ,"Distusrs", var _Distdisps = [Distdisps] var _test = DISTINCT(SELECTCOLUMNS( FILTER(_t ,[Distdisps]=_Distdisps),"uid" ,[UID])) return COUNTROWS(_test) )
var _cur_num = VALUES('Number'[Column1])
var _t3 = FILTER(_t2 , [Distdisps] in _cur_num)
return
SUMX(_t3 , [Distusrs])
Then we can put this measure on the visual like this , the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 84 | |
| 48 | |
| 36 | |
| 31 | |
| 29 |