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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Antmkjr
Helper V
Helper V

How to implement the below dax in power query

I am fairly new to power query,
 
The below logic is of a calculated column, how to implement the same in power query:
 
Flag =
IF (
'Discoverer- AP Payment 1 - Summary'[Difference] = 0,
"Matched",
IF (
AND (
OR (
'Discoverer- AP Payment 1 - Summary'[Discoverer Amount] = BLANK (),
ROUND ( 'Discoverer- AP Payment 1 - Summary'[Discoverer Amount], 0 ) = 0
),
'Discoverer- AP Payment 1 - Summary'[Difference] <> 0
),
"Ignore",
IF (
AND (
'Discoverer- AP Payment 1 - Summary'[AP Amount] = 0,
ROUND ( 'Discoverer- AP Payment 1 - Summary'[Discoverer Amount], 0 ) <> 0
),
"Void/Unmatched",
"Unmatched"
)
)
)
1 ACCEPTED SOLUTION

Hi @Antmkjr ,

What error do you get? Make sure you choose correct types for your columns (Decimal numbers for DA,Difference,AP).

if [Difference] = 0 
then "Matched"
else if ([DA]=null or Number.Round([DA],0) = 0) and [Difference] <> 0 
then "Ignore" 
else if [#"AP "] = 0 and Number.Round([DA],0) <> 0 
then "Void/Unmatched" 
else "Unmatched"

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

6 REPLIES 6
StefanoGrimaldi
Resident Rockstar
Resident Rockstar

SOMETHING LIKE THIS (REMEBER YOU NEED TO BREAK DOWN THE MEASURE HERE FOR IT TO WORK ALSO): 

IF

(Discoverer- AP Payment 1 - Summary'[Difference]) = 0 then

"Matched",

Else IF

 

('Discoverer- AP Payment 1 - Summary'[Discoverer Amount] = null OR

Number.ROUND( 'Discoverer- AP Payment 1 - Summary'[Discoverer Amount], 0 ) = 0) AND

'Discoverer- AP Payment 1 - Summary'[Difference] <> 0

 

Then

"Ignore",

Else IF 

('Discoverer- AP Payment 1 - Summary'[AP Amount] = 0 AND

NUMBER.ROUND ( 'Discoverer- AP Payment 1 - Summary'[Discoverer Amount], 0 ) <> 0) THEN

"Void/Unmatched" ELSE "Unmatched"





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




I have tried this but getting error, not able to understand what is wrong:

 

if

[Difference] = 0 then

"Matched"

else if

[Discoverer Amount] = null OR

Number.ROUND( [Discoverer Amount], 0 ) = 0) AND

[Difference] <> 0

Then

"Ignore",

Else IF

([AP Amount] = 0 AND

NUMBER.ROUND ( [Discoverer Amount], 0 ) <> 0) THEN

"Void/Unmatched" ELSE "Unmatched"

try this: 

if

[Difference] = 0 then

"Matched"

else if

([Discoverer Amount] = null) OR

(Number.ROUND( [Discoverer Amount], 0 ) = 0 AND

[Difference] <> 0)

Then

"Ignore",

Else IF

([AP Amount] = 0 AND

NUMBER.ROUND ( [Discoverer Amount], 0 )) <> 0 THEN

"Void/Unmatched" ELSE "Unmatched"

 

if doesnt work send a sample data or a sample PBIX to fix it and give the exact Mquery formula.





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Hi @Antmkjr ,

What error do you get? Make sure you choose correct types for your columns (Decimal numbers for DA,Difference,AP).

if [Difference] = 0 
then "Matched"
else if ([DA]=null or Number.Round([DA],0) = 0) and [Difference] <> 0 
then "Ignore" 
else if [#"AP "] = 0 and Number.Round([DA],0) <> 0 
then "Void/Unmatched" 
else "Unmatched"

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

StefanoGrimaldi
Resident Rockstar
Resident Rockstar

first I see you have measure inside that dax, Power Query doesnt use measure you need to break those down to it logical code, its pretty much the same except for the functions name but basically copy that code, delete all parentesis and comas for the ifs, the logic of if its as follow 

 

if Column 1 > column 2 and column 2 > 3   then 1 else 2    --> if you want to imput text its the same use "1" intead of number 1 it will insert the value as a text for thta column. you cant mix datatype on the results. 

equivalent of blank() --> null 

round its --> number.round





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors