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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors