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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Convert DAX to M Query

Hi all.

I have a requirement wherein I want to convert DAX logic into M query.

Below is the DAX query which I am looking to convert.

TabIndexParent = IF(Tab[ParentTab]="00000000-0000-0000-0000-000000000000",
Tab[TabIndex],
LOOKUPVALUE(Tab[TabIndex],
Tab[Key],
Tab[ParentTab] & Tab[BID]))
 
 
Thanks,
Sanket
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @amitchandak @V-lianl-msft  thanks for your suggestions.
Those suggestions did help somewhat but not totally.
I implemented the following steps to arrive at the output;
1)Go to Query EDditor, duplicate the original table. Go to 'Choose Columns' and select columns which you want to use as a KEY to lookup. In my case they were 'Tab' and 'TabIndex'.
2) Again Duplicate the original table and filter ParentTab for non-zero values.
Merge this table with the Lookup table on 'Tab' from current table and 'ParentTab' from Lookup table.
3)Select TabIndex from the expanded tab.
4)Again duplicate the original table and filter 'ParentTab' for "00000000-0000-0000-0000-000000000000".
5)Append both the tables.


 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @amitchandak @V-lianl-msft  thanks for your suggestions.
Those suggestions did help somewhat but not totally.
I implemented the following steps to arrive at the output;
1)Go to Query EDditor, duplicate the original table. Go to 'Choose Columns' and select columns which you want to use as a KEY to lookup. In my case they were 'Tab' and 'TabIndex'.
2) Again Duplicate the original table and filter ParentTab for non-zero values.
Merge this table with the Lookup table on 'Tab' from current table and 'ParentTab' from Lookup table.
3)Select TabIndex from the expanded tab.
4)Again duplicate the original table and filter 'ParentTab' for "00000000-0000-0000-0000-000000000000".
5)Append both the tables.


 

V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

1. Create a merged column in power query:

Vlianlmsft_0-1645770944635.png

2. Create a merge query in the same table:

Vlianlmsft_1-1645771022875.png

Expand the index column in the table to get the desired results.

Vlianlmsft_2-1645771101872.png

 

 

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

amitchandak
Super User
Super User

@Anonymous , seem like you need lookup in power query,

 

refer if these can help

https://www.youtube.com/watch?v=3mgCXA7DD3U

https://www.myonlinetraininghub.com/vlookup-in-power-query-using-list-functions

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

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Solution Authors