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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Auto generate Table by data and condition from other table

HI friend

 

I don't sure power bi will be able to do this.
But can someone advise me how to create table2 that all column auto generate data from table1 by each row are information from each lesson that value 1 individual by day

 

Table1

Date                name               lesson1            lesson2            lesson3           lesson4
01-JanJame11  
01-JanKelly 1  
02-JanJame1   
03-JanJame  1 
02-JanKelly  11

 

Table2 (auto generate)

Date                name               Suject
01-JanJamelesson1
01-JanJamelesson2
01-JanKellylesson2
02-JanJamelesson1
03-JanJamelesson3
02-JanKellylesson3
02-JanKellylesson4

 

Thanks a lot in advance for your help.

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@Anonymous - Just select your four lesson columns and unpivot them in Power Query. If you want a DAX method, there is a way to achieve unpivot in DAX also: https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832#M256



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@Anonymous 

.I used @Greg_Deckler's technique to union each column and filter then added a tweak to include column names.

You will have to hardcode our column names as I have done below.
 

 

LESSONS DAX = 
FILTER(
    UNION(
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson1] = "1", "Lesson 1", BLANK())), 
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson2] = "1", "Lesson 2", BLANK())),
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson3] = "1", "Lesson 3", BLANK())),
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson4] = "1", "Lesson 4", BLANK()))
    ),
    [LESSON] <> BLANK()
)

 

 
Result.

Fowmy_0-1596958848685.png

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@Anonymous , refer if this can help

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak Is it possible to only use it as DAX?

Anonymous
Not applicable

@Fowmy  thank for you advice!! but all lesson column in Table is calculated columnม Is it possible to use it as DAX? : (

@Anonymous 

.I used @Greg_Deckler's technique to union each column and filter then added a tweak to include column names.

You will have to hardcode our column names as I have done below.
 

 

LESSONS DAX = 
FILTER(
    UNION(
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson1] = "1", "Lesson 1", BLANK())), 
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson2] = "1", "Lesson 2", BLANK())),
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson3] = "1", "Lesson 3", BLANK())),
        SELECTCOLUMNS( LESSONS , "DATE", [Date] , "NAME" , [name] , "LESSON", IF([lesson4] = "1", "Lesson 4", BLANK()))
    ),
    [LESSON] <> BLANK()
)

 

 
Result.

Fowmy_0-1596958848685.png

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy Thank you so much for your nice description and details , i have tested it and its great : )

Greg_Deckler
Community Champion
Community Champion

@Anonymous - Just select your four lesson columns and unpivot them in Power Query. If you want a DAX method, there is a way to achieve unpivot in DAX also: https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832#M256



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thank you so much , its worked like my way!!

Fowmy
Super User
Super User

@Anonymous 

It's absolutely possible!

Easy to do it in Power Query with just two steps
1. Your data look like this at the beginning, Select Date and Name columns and right-click, select Unpivot Other Columns,

Fowmy_1-1596907744445.png


2. Click on the filter button on the Value column and deselect blank, done. You can remove the value column.

Fowmy_2-1596907778387.png
3. Result

Fowmy_0-1596907694323.png



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.