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
ChoiJunghoon
Helper III
Helper III

DAX -Create New table

HI

I can't think how to create new table by using DAX formula. 

TableA

CategoryCharge
A3
B4
C2
D1

 

TableB

Index
1
2
3
4
5
6
7
8
9
10

 

I wanto to create the NewTable 

Result

IndexCategory
1A
2A
3A
4B
5B
6B
7B
8C
9C
10D

 

Could you help me ? 

 

2 ACCEPTED SOLUTIONS
wdx223_Daniel
Super User
Super User

Jihwan_Kim
Super User
Super User

Hi, @ChoiJunghoon 

Please check the below picture and the sample pbix file's link down below.

 

Picture2.png

 

Result Table =
VAR rankAaddcolumn =
ADDCOLUMNS ( TableA, "@rankcategory", RANKX ( TableA, TableA[Category],, ASC ) )
VAR cumulateaddcolumn =
ADDCOLUMNS (
rankAaddcolumn,
"@cumulatemax",
SUMX (
FILTER ( rankAaddcolumn, [@rankcategory] <= EARLIER ( [@rankcategory] ) ),
TableA[Charge]
)
)
VAR cumulateaddcolumnstep2 =
ADDCOLUMNS (
cumulateaddcolumn,
"@cumulatemin",
SUMX (
FILTER ( cumulateaddcolumn, [@rankcategory] = EARLIER ( [@rankcategory] ) - 1 ),
[@cumulatemax]
)
)
VAR addtoindexcolumn =
ADDCOLUMNS (
TableB,
"Category",
SUMMARIZE (
FILTER (
cumulateaddcolumnstep2,
[@cumulatemin] < TableB[Index]
&& [@cumulatemax] >= TableB[Index]
),
TableA[Category]
)
)
RETURN
addtoindexcolumn

 

 

https://www.dropbox.com/s/voz6y9o9e04cht3/choijunghoon.pbix?dl=0 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @ChoiJunghoon 

Please check the below picture and the sample pbix file's link down below.

 

Picture2.png

 

Result Table =
VAR rankAaddcolumn =
ADDCOLUMNS ( TableA, "@rankcategory", RANKX ( TableA, TableA[Category],, ASC ) )
VAR cumulateaddcolumn =
ADDCOLUMNS (
rankAaddcolumn,
"@cumulatemax",
SUMX (
FILTER ( rankAaddcolumn, [@rankcategory] <= EARLIER ( [@rankcategory] ) ),
TableA[Charge]
)
)
VAR cumulateaddcolumnstep2 =
ADDCOLUMNS (
cumulateaddcolumn,
"@cumulatemin",
SUMX (
FILTER ( cumulateaddcolumn, [@rankcategory] = EARLIER ( [@rankcategory] ) - 1 ),
[@cumulatemax]
)
)
VAR addtoindexcolumn =
ADDCOLUMNS (
TableB,
"Category",
SUMMARIZE (
FILTER (
cumulateaddcolumnstep2,
[@cumulatemin] < TableB[Index]
&& [@cumulatemax] >= TableB[Index]
),
TableA[Category]
)
)
RETURN
addtoindexcolumn

 

 

https://www.dropbox.com/s/voz6y9o9e04cht3/choijunghoon.pbix?dl=0 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1624494945460.pngwdx223_Daniel_1-1624494960023.png

 

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.