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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
AliceW
Power Participant
Power Participant

Convert a multiple IF formula from DAX to M

Hi folks,

I am terrible at M and I really need this formula in the Power Query so that I can then unpivot the table. Could anybody help me, please?

 

2019-01 =
SWITCH('Business'[Line],
"Lyme",
if(AND(related(Business[Close Date])<=date(2019,01,31),related(Business[Close Date])>=date(2019,01,01)),
[Amount]),
"Mountain",
if(and(related(Business[Start Date])<=date(2019,01,31),related(Business[End Date])>=date(2019,01,01)),
divide('Row'[Amount],'Row'[Term]))
"Earth",
if(and(related(Business[Start Date])<=date(2019,01,31),related(Business[Start Date])>=date(2019,01,01)),
('Row'[Amount]*0.6),
if(and(related(Opp[Start Date])<=date(2019,01,31),related(Opp[End Date])>=date(2019,01,01)),
divide('Row'[Amount]*0.4,'Row'[Term])))
)

 

If 'related' doesn't work, I can easily calculate these columns in the 'Row' table.

A big thank you.

Alice

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @AliceW 

 

Please provide the dummy pbix that we can test it on the exit data directly. 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
lbendlin
Super User
Super User

M is much simpler than DAX in this respect. All it has is and and or. No fancy switch syntax sugar.

Keep in mind that in Power Query your tables are not yet related.  You either need to merge tables, or use custom column generator functions to lookup values in other tables.

 

Best would be to provide sample data for your row data source and business data source.

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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