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
BeastHouse
Frequent Visitor

Converting Excel Workbook to Power BI DAX

Hi, I have several big formulas sitting in an existing Excel workbook that I need to transfer over to Power BI, however I have no idea how to convert these ones. Some are using the MATCH function from Excel, others I fear may be too long. If someone can provide some advice on how to make these work in DAX, that would be appreciated.

 

I have more, but I think if I can understand how to acheive the below, it will help with the others.

 

Month of Invoice

 

This one looks at the following new fields in Power BI

 

  • 'Invoice Number' in TEXT format
  • 'Month' in TEXT format

 

=IFERROR(IF([@[Invoice Number]]<>"",TEXT(INDEX(tbl_InvoiceNumbers[Month],MATCH([@[Invoice Number]],tbl_InvoiceNumbers[Invoice Number],0),),"mmmm"),""),"")

 

 

EDD

 

I have put this into Power BI as it looked simple enough, however it did not work.

 

'Quoted EDD' is in DATE format.

 

 

EDD = IF('Stock Orders'[Quoted EDD]="","",IF('Stock Orders'[Quoted EDD]=1,"",'Stock Orders'[Quoted EDD]))

 

 

It receives error DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

Date Ordered

I have put this into Power BI as it looked simple enough, however it did not work either.

 

'Date Submitted' is in DATE format.

 

 

Date Ordered = IF('Stock Orders'[Date Submitted]="",IF('Stock Orders'[PP]="PP1",DATE(2015,7,1),IF('Stock Orders'[PP]="PP2",DATE(2016,7,1),IF('Stock Orders'[PP]="PP3",DATE(2017,7,1),IF('Stock Orders'[PP]="PP4",DATE(2018,7,1),IF('Stock Orders'[PP]="PP5",DATE(2019,7,1),IF('Stock Orders'[PP]="PP6",DATE(2020,7,1),IF('Stock Orders'[PP]="PP7",DATE(2021,7,1),IF('Stock Orders'[PP]="PP8",DATE(2022,7,1),IF('Stock Orders'[PP]="PP9",DATE(2023,7,1),'Stock Orders'[Date Submitted]))))))))),'Stock Orders'[Date Submitted])

 

 

It receives error DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

1 ACCEPTED SOLUTION
ERD
Super User
Super User

@BeastHouse 

EDD = IF('Stock Orders'[Quoted EDD]="","",IF('Stock Orders'[Quoted EDD]=1,"",'Stock Orders'[Quoted EDD]))

 

If 'Stock Orders'[Quoted EDD] is of Date type, why would you compare it to '1'?

If you want to check if the field is empty, use Stock Orders'[Quoted EDD] = BLANK()And use the same BLANK() instead of leaving "" when your column is supposed to be of a Date type.

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

3 REPLIES 3
ERD
Super User
Super User

@BeastHouse 

EDD = IF('Stock Orders'[Quoted EDD]="","",IF('Stock Orders'[Quoted EDD]=1,"",'Stock Orders'[Quoted EDD]))

 

If 'Stock Orders'[Quoted EDD] is of Date type, why would you compare it to '1'?

If you want to check if the field is empty, use Stock Orders'[Quoted EDD] = BLANK()And use the same BLANK() instead of leaving "" when your column is supposed to be of a Date type.

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!

Thanks @ERD - I wasn't aware of the BLANK() function. Thats a great help.

 

Do you know how I can also do a MATCH function in DAX? Another formula I am trying to convert from Excel is below. You'll have to forgive me, as I didn't write the original Workbook, so really trying to unjumble what the author had written.


=IFERROR(INDEX(tbl_ProcRep_Stock_CV[Ref],MATCH([@[RFQ ID]],tbl_ProcRep_Stock_CV[RFQ ID],0)),"")

 

@BeastHouse , check LOOKUPVALUE function (DAX) - DAX | Microsoft Learn

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!

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