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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
japolo
Frequent Visitor

Multiple values for the same ID

Hi,

I'm have a fact table where the ID is shown multiple times since the ID can have multiple events. I want to summarize the number of IDs that have had e.g. add_to_cart and add_to_wishlist. How should I go by with a measure, alternatively a custom column? I'm not sure about the DAX code needed to be able to do it. Something like if a session has add_to_cart and add_to_wishlist, return 1, else 0.

japolo_0-1663772585597.png

Kind regards,

J

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@japolo you can add a measure to get the ids that meets the condition

 

Count Measure = 
VAR __addtocartTable = CALCULATETABLE ( VALUES ( Table[ID] ), Table[Event] = "add_to_cart" )
VAR __addtowishTable = CALCULATETABLE ( VALUES ( Table[ID] ), Table[Event] = "add_to_wishlist" )
RETURN
COUNTROWS ( INTERSECT  ( __addtocartTable, __addtowishTable ) )

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

v-rzhou-msft
Community Support
Community Support

Hi @japolo ,

 

Sample:

RicoZhou_1-1663829102290.png

I suggest you to create a virtual table in your measure.

Measure = 
VAR _SUMMAIRZE  = SUMMARIZE('Table',[session_id],"Flag",VAR _EVENT_LIST = CALCULATETABLE(VALUES('Table'[event]),ALLEXCEPT('Table','Table'[session_id]))
Return
IF(AND( "add_to_cart" IN _EVENT_LIST ,"add_to_wishlist" IN _EVENT_LIST),1,0))
RETURN
COUNTAX(FILTER(_SUMMAIRZE,[Flag] = 1),[session_id])

Result is as below.

RicoZhou_0-1663829079695.png

 

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.

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @japolo ,

 

Sample:

RicoZhou_1-1663829102290.png

I suggest you to create a virtual table in your measure.

Measure = 
VAR _SUMMAIRZE  = SUMMARIZE('Table',[session_id],"Flag",VAR _EVENT_LIST = CALCULATETABLE(VALUES('Table'[event]),ALLEXCEPT('Table','Table'[session_id]))
Return
IF(AND( "add_to_cart" IN _EVENT_LIST ,"add_to_wishlist" IN _EVENT_LIST),1,0))
RETURN
COUNTAX(FILTER(_SUMMAIRZE,[Flag] = 1),[session_id])

Result is as below.

RicoZhou_0-1663829079695.png

 

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.

 

parry2k
Super User
Super User

@japolo you can add a measure to get the ids that meets the condition

 

Count Measure = 
VAR __addtocartTable = CALCULATETABLE ( VALUES ( Table[ID] ), Table[Event] = "add_to_cart" )
VAR __addtowishTable = CALCULATETABLE ( VALUES ( Table[ID] ), Table[Event] = "add_to_wishlist" )
RETURN
COUNTROWS ( INTERSECT  ( __addtocartTable, __addtowishTable ) )

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors