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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
CLQ
Helper I
Helper I

Get the repeated values ​​in a table, using, if possible, calculatedtable

Hello everyone.

I have the following table (Table1):

NameOrder Date DayMonthStore
Jhon2022/06/0116TV
Jhon2022/06/0116TV
Jhon2022/07/0117TV
Kelly2022/06/0116Phone
Kelly2022/06/0156Phone
Fred2022/06/0116TV
Fred2022/06/0116Phone
Mark2022/06/0556TV
Mark2022/06/0556Xbox
Jes2022/08/12128TV

 

 

So, in a variable using calculatedtable, I look for the values ​​(Names) to be saved, which have bought two or more times in Store=TV or Xbox , in month six. The expected result, taking the table above, would be:

Jhon
Mark



What I tried, creating another table and trying to "simulate" the values ​​that said variable would bring, was:

 


CALCULATEDTABLE(VALUES(Table1[Name]),
NOT(Table1[Store]) = "Phone",
Table1[Month]=6,
FILTER(ALL(Table1), CALCULATE(COUNTROWS(Table1), ALL(Table1), VALUES(Table1[Name]))>=2)

But without result (it kept bringing me all the values ​​of month 6, regardless of the number of occurrences of "Name"). If anyone knows how to do it, I'd appreciate it 🙂

 

 

PS: for those who want to know the context of this:

My idea is, for example, in variable1, to obtain all the names that were repeated two or more times in month six.
Then, in variable2, get all the values ​​that appear in month 7, regardless of the number of times they appear.
The next step is, using INTERCEPT, to obtain the number of users that appear in variable2 that have appeared in variable1.
Obviously I have to create more rows to do this, but first I want for the first step to work out, which is the one that is not working for me 😑

 

 

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @CLQ ,

 

You can try this method:

Result =
VAR _table =
    FILTER (
        'Table',
        AND ( 'Table'[Month] = 6, 'Table'[Store] = "TV" || 'Table'[Store] = "Xbox" )
    )
VAR _table1 =
    GROUPBY ( _table, [Name], "num", COUNTX ( CURRENTGROUP (), [Name] ) )
RETURN
    SUMMARIZE ( FILTER ( _table1, [num] > 1 ), [Name] )

The result is:

vyinliwmsft_0-1669887130563.png

Hope this helps you.

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

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-yinliw-msft
Community Support
Community Support

Hi @CLQ ,

 

You can try this method:

Result =
VAR _table =
    FILTER (
        'Table',
        AND ( 'Table'[Month] = 6, 'Table'[Store] = "TV" || 'Table'[Store] = "Xbox" )
    )
VAR _table1 =
    GROUPBY ( _table, [Name], "num", COUNTX ( CURRENTGROUP (), [Name] ) )
RETURN
    SUMMARIZE ( FILTER ( _table1, [num] > 1 ), [Name] )

The result is:

vyinliwmsft_0-1669887130563.png

Hope this helps you.

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Greg_Deckler
Super User
Super User

@CLQ Try:

Table = 
  VAR __Table = GROUBY(FILTER('Table',[Store] <> "Phone" && [Month] = 6),[Name],"__Count",COUNTX(CURRENTGROUP(),[Order Date]))
  VAR __Result = FILTER(__Table,[__Count] > 1)
RETURN
  __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.