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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
JiriRak
Helper I
Helper I

Creating table from a table

Hi,

As usually, this was meant to be a quick modification to my model ...

There is a table that contains:

- Hedge type (1 or 2),

- Contract ID,

- Hedge ID.

Many Contracts ID have been hedged by 1 and 2.

Some of them  have been hedged more than once, i.e. there are a few Contract ID with more than one Hedge ID within the Hedge type.

I want to create two tables:

- with the values where Contract ID has got only one Hedge ID within the Hedge type,

- with the value where Contract ID has got more than one Hedge ID within the Hedge type.

How can I do it?

And where should I do it - query or desktop? 

I thought because it´s conditional, desktop would be better.

Principally, I need to filter out a table where the rows where Total is bigger than 2 would be missing.

Snímek obrazovky 2022-09-20 221122.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @JiriRak ,

I created some data:

vyangliumsft_0-1663724322871.png

Here are the steps you can follow:

Create calculated table.

Table 1 =
var _table=
SUMMARIZE(
    'Table','Table'[Contract ID],'Table'[Hedge type],'Table'[Hedge ID],
    "Count",COUNTX(FILTER(ALL('Table'),'Table'[Contract ID]=EARLIER('Table'[Contract ID])),[Hedge ID]))
var _table2=
FILTER(
    _table,[Count]<=2)
return
SUMMARIZE(_table2,[Contract ID],[Hedge type],[Hedge ID])

vyangliumsft_1-1663724322872.png

Table 2 =
var _table=
SUMMARIZE(
    'Table','Table'[Contract ID],'Table'[Hedge type],'Table'[Hedge ID],
    "Count",COUNTX(FILTER(ALL('Table'),'Table'[Contract ID]=EARLIER('Table'[Contract ID])),[Hedge ID]))
var _table2=
FILTER(
    _table,[Count]>2)
return
SUMMARIZE(_table2,[Contract ID],[Hedge type],[Hedge ID])

vyangliumsft_2-1663724322874.png

If you want to implement filtering data greater than 2 of Total in a matrix:

Create measure.

Count_measure =
COUNTX(FILTER(ALL('Table'),'Table'[Contract ID]=MAX('Table'[Contract ID])),[Hedge ID])
Flag =
IF(
    [Count_measure]<=2,1,0)

Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_3-1663724322875.png

Result:

vyangliumsft_4-1663724322875.png

 

Best Regards,

Liu Yang

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
Anonymous
Not applicable

Hi  @JiriRak ,

I created some data:

vyangliumsft_0-1663724322871.png

Here are the steps you can follow:

Create calculated table.

Table 1 =
var _table=
SUMMARIZE(
    'Table','Table'[Contract ID],'Table'[Hedge type],'Table'[Hedge ID],
    "Count",COUNTX(FILTER(ALL('Table'),'Table'[Contract ID]=EARLIER('Table'[Contract ID])),[Hedge ID]))
var _table2=
FILTER(
    _table,[Count]<=2)
return
SUMMARIZE(_table2,[Contract ID],[Hedge type],[Hedge ID])

vyangliumsft_1-1663724322872.png

Table 2 =
var _table=
SUMMARIZE(
    'Table','Table'[Contract ID],'Table'[Hedge type],'Table'[Hedge ID],
    "Count",COUNTX(FILTER(ALL('Table'),'Table'[Contract ID]=EARLIER('Table'[Contract ID])),[Hedge ID]))
var _table2=
FILTER(
    _table,[Count]>2)
return
SUMMARIZE(_table2,[Contract ID],[Hedge type],[Hedge ID])

vyangliumsft_2-1663724322874.png

If you want to implement filtering data greater than 2 of Total in a matrix:

Create measure.

Count_measure =
COUNTX(FILTER(ALL('Table'),'Table'[Contract ID]=MAX('Table'[Contract ID])),[Hedge ID])
Flag =
IF(
    [Count_measure]<=2,1,0)

Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_3-1663724322875.png

Result:

vyangliumsft_4-1663724322875.png

 

Best Regards,

Liu Yang

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

Amazing, thank you, I got really crazy yesterday with the SUMMARIZE and VAR, and couldn´t get through.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.