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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

zero for dubble value

Hi, 

 

I made a dashboard that measures several metrics of a certain animal-related company. A problem is that the data comes in quite messy so to get my filters to work I have to register all data into a combined Query. Not really a problem normally but since I want to count both the number of users and the number of pets it is one now. The thing is, one user ID has several pet ID's linked to it, which in turn gives double values. Normally you would delete those but if I do that it deletes all pets but one. So at the moment, It looks like this for example:

 

WhatsApp Image 2021-06-22 at 14.07.01.jpeg

through the index, it can only count the number of pets but not the user. 

 

So I am kinda looking for a function similar to: IF [user_id] IS 'DUBBLE.VALUE' THEN [index] IS 'ZERO' so it will only count the users one time while still counting all the pets. 

 

I've been looking for days but cannot find the answer anywhere online or offline so maybe somebody has a solution here?

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

You can try this in blank query.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXLWc8pJzMsGspL1kkAsh/zSkpz8/Gy95PxcoKihoZkBkHLJTweSbplpICGlWB2iNYOVJZYASaf8osxiUrUbwe32TayAawaJBugFl2eCVBUDKXSNxkYgRwclJmWCbHbLKU0jRS/IbcEZqakFIFcXVcK1GgNZjnq+UH8k6uXmO6TnJmbmwHSaGCGc61iUCNEXCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"User ID" = _t, User = _t, Email = _t, Pet = _t, Sort = _t, Name = _t, Index = _t]),
    #"Grouped Rows" = Table.Group(Source, {"User ID"}, {{"Gr", each Table.AddColumn(Table.AddIndexColumn(_,"Help", 0,1), "Index2", each if [Help]=0 then 1 else 0)}}),
    #"Expanded Gr" = Table.ExpandTableColumn(#"Grouped Rows", "Gr", {"User", "Email", "Pet", "Sort", "Name", "Index", "Index2"}, {"User", "Email", "Pet", "Sort", "Name", "Index", "Index2"})
in
    #"Expanded Gr"

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

@Jakinta 's solution looks great. Does it solve your problem? If it's not what you want, could you show what should be the expected result in Index column (or a new column)?

 

Regards,
Community Support Team _ Jing

Jakinta
Solution Sage
Solution Sage

You can try this in blank query.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXLWc8pJzMsGspL1kkAsh/zSkpz8/Gy95PxcoKihoZkBkHLJTweSbplpICGlWB2iNYOVJZYASaf8osxiUrUbwe32TayAawaJBugFl2eCVBUDKXSNxkYgRwclJmWCbHbLKU0jRS/IbcEZqakFIFcXVcK1GgNZjnq+UH8k6uXmO6TnJmbmwHSaGCGc61iUCNEXCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"User ID" = _t, User = _t, Email = _t, Pet = _t, Sort = _t, Name = _t, Index = _t]),
    #"Grouped Rows" = Table.Group(Source, {"User ID"}, {{"Gr", each Table.AddColumn(Table.AddIndexColumn(_,"Help", 0,1), "Index2", each if [Help]=0 then 1 else 0)}}),
    #"Expanded Gr" = Table.ExpandTableColumn(#"Grouped Rows", "Gr", {"User", "Email", "Pet", "Sort", "Name", "Index", "Index2"}, {"User", "Email", "Pet", "Sort", "Name", "Index", "Index2"})
in
    #"Expanded Gr"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors