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

Create New Table with Dax

Hello  

I want to create the result table with Dax. 
Could you help me ? 
TableA

CatergoryValue
A5
B8
C12

 

TableB

CatergoryCharge
A2
B3
C4

 

ResultTable

CategoryNumber
A6
A7
B9
B10
B11
C13
C14
C15
C16
1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

 

SELECTCOLUMNS(
    GENERATE(
        TableA,
        var Val = TableA[Value]
        var Cat = TableA[Category]
        var Chrg = 
            LOOKUPVALUE(
                TableB[Charge],
                TableB[Category], Cat,
                BLANK()
            )
        var Nums = 
            SELECTCOLUMNS(
                GENERATESERIES(
                    Val + 1, 
                    Val + Chrg,
                    1
                ),
                "@Number", [Value]
            )
        return
            Nums
    ),
    "Category", TableA[Category],
    "Number", [@Number]
)

View solution in original post

3 REPLIES 3
daxer-almighty
Solution Sage
Solution Sage

Another way would be:

SELECTCOLUMNS(
    GENERATE(
        NATURALINNERJOIN(
            TableA,
            TableB
        ),
        var Val = TableA[Value]
        var Cat = TableA[Category]
        var Chrg = TableB[Charge]
        var Nums = 
            SELECTCOLUMNS(
                GENERATESERIES(
                    Val + 1, 
                    Val + Chrg,
                    1
                ),
                "@Number", [Value]
            )
        return
            Nums
    ),
    "Category", TableA[Category],
    "Number", [@Number]
)
daxer-almighty
Solution Sage
Solution Sage

 

SELECTCOLUMNS(
    GENERATE(
        TableA,
        var Val = TableA[Value]
        var Cat = TableA[Category]
        var Chrg = 
            LOOKUPVALUE(
                TableB[Charge],
                TableB[Category], Cat,
                BLANK()
            )
        var Nums = 
            SELECTCOLUMNS(
                GENERATESERIES(
                    Val + 1, 
                    Val + Chrg,
                    1
                ),
                "@Number", [Value]
            )
        return
            Nums
    ),
    "Category", TableA[Category],
    "Number", [@Number]
)

Thank you So much!!

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.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.