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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

need to create a new table with existing table

Hi, I have a table like below,

 

Herndon_powerbi_0-1639602468286.png

I want to create a new table based on the above table

Herndon_powerbi_1-1639602527461.png

   Please let me know how to create the new table with DAX. Thanks in advance.

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Herndon_powerbi 

 

Try this code:

Table 2 =
VAR _A =
    SUMMARIZE ( 'Table', 'Table'[Student], "count-id", COUNTA ( 'Table'[Student] ) )
VAR _B =
    ROW (
        "student", "movie1-yes",
        "count-id", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[movie1] = "yes" )
    )
VAR _C =
    ROW (
        "student", "movie2-no",
        "count-id", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[movie2] = "no" )
    )
RETURN
    UNION ( _A, _B, _C )

 

output:

VahidDM_0-1639615009719.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

6 REPLIES 6
VahidDM
Super User
Super User

Hi @Herndon_powerbi 

 

Try this code:

Table 2 =
VAR _A =
    SUMMARIZE ( 'Table', 'Table'[Student], "count-id", COUNTA ( 'Table'[Student] ) )
VAR _B =
    ROW (
        "student", "movie1-yes",
        "count-id", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[movie1] = "yes" )
    )
VAR _C =
    ROW (
        "student", "movie2-no",
        "count-id", CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[movie2] = "no" )
    )
RETURN
    UNION ( _A, _B, _C )

 

output:

VahidDM_0-1639615009719.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi,

     Your solution is correct but I need to use several page filters for this visual. Because I am using the above-mentioned DAX, none of the page filters are applicable. Values are not changing. I want to know how can I overcome this error. Thanks in advance

Hi,

     Please ignore my previous requests, your query is working fine.

 

Thanks,

Herndon_Powerbi

Hi,

      Your solution is correct but it is counting blank values in the column.

I don't want blank values. Please help me.

Thanks in advance,

 @Herndon_powerbi 

 

Hi,

       Thanks for your solution. I have 4 filters for this query all from different tables. I included them in the page filter. but it seems they are not effective. what should I do to make them effective?

 

 

Thanks

 

 

smpa01
Super User
Super User

@Herndon_powerbi 

Calculated Table=
VAR _1 =
    ADDCOLUMNS (
        VALUES ( 'Table'[Student] ),
        "count-id", CALCULATE ( COUNT ( 'Table'[Student] ) )
    )
VAR _2 =
    SELECTCOLUMNS (
        ADDCOLUMNS (
            FILTER ( VALUES ( 'Table'[movie1] ), 'Table'[movie1] = "yes" ),
            "count-id", CALCULATE ( COUNT ( 'Table'[movie1] ) )
        ),
        "Student", [movie1],
        "count-id", [count-id]
    )
VAR _3 =
    SELECTCOLUMNS (
        ADDCOLUMNS (
            FILTER ( VALUES ( 'Table'[movie2] ), 'Table'[movie2] = "yes" ),
            "count-id", CALCULATE ( COUNT ( 'Table'[movie2] ) )
        ),
        "Student", [movie2],
        "count-id", [count-id]
    )
RETURN
    UNION ( _1, _2, _3 )
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.