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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Jelena_I
Regular Visitor

DAX Power BI- Need a help on Formula

Dear All,

 

I would apprecaite, if you could help me to find an error in the formula below.

 

Month_Groups = SWITCH(TRUE(),
AND(MYK_AD_20230428[Date_Month]<12),"Less than 12 Month",
 AND(MYK_AD_20230428[Date_Month]>12, MYK_AD_20230428[Date_Month]<24),"12-24",
  AND(MYK_AD_20230428[Date_Month]>24, MYK_AD_20230428[Date_Month]<36),"24-36",
  MYK_AD_20230428[Date_Month]>36,"36+"BLANK())
 
The error message as following: Too few arguments were passed to the AND function. The minimum argument count for the function is 2.
 
It should group the data after month. 
 
Thank you in advance. 
 
Best regards
Jelena
1 ACCEPTED SOLUTION

Hi Jelena,

 

Thank you for your prompt response. Could you possibly please try the following:

Month_Groups =
SWITCH(
    TRUE(),
    MYK_AD_20230428[Date_Month] < 12, "Less than 12 Month",
    AND(MYK_AD_20230428[Date_Month] > 12, MYK_AD_20230428[Date_Month] < 24), "12-24",
    AND(MYK_AD_20230428[Date_Month] > 24, MYK_AD_20230428[Date_Month] < 36), "24-36",
    MYK_AD_20230428[Date_Month] > 36, "36+",
    BLANK()
)

Let me know if you might need further assistance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

5 REPLIES 5
Jelena_I
Regular Visitor

Dear Sahir, thank you very much for your answer. Unfortunately, the error is the same. It shows, that there is an error in this line:

AND(MYK_AD_20230428[Date_Month]<12),"Less than 12 Month",
 
Thank you in advance. 
 
Best regards,
Jelena

Hi Jelena,

 

Thank you for your prompt response. Could you possibly please try the following:

Month_Groups =
SWITCH(
    TRUE(),
    MYK_AD_20230428[Date_Month] < 12, "Less than 12 Month",
    AND(MYK_AD_20230428[Date_Month] > 12, MYK_AD_20230428[Date_Month] < 24), "12-24",
    AND(MYK_AD_20230428[Date_Month] > 24, MYK_AD_20230428[Date_Month] < 36), "24-36",
    MYK_AD_20230428[Date_Month] > 36, "36+",
    BLANK()
)

Let me know if you might need further assistance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Dear Sahir

 

It worked, thank you very much. You are hero. 

 

Best regards,

Jelena

Happy to help! Should you require any further assistance, do not hesitate to reach out to me 🙂


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
Sahir_Maharaj
Super User
Super User

Hello @Jelena_I,

 

To fix this issue, you need to modify the formula as follows:

 

Month_Groups = SWITCH(TRUE(),
    AND(MYK_AD_20230428[Date_Month]<12),"Less than 12 Month",
    AND(MYK_AD_20230428[Date_Month]>12, MYK_AD_20230428[Date_Month]<24),"12-24",
    AND(MYK_AD_20230428[Date_Month]>24, MYK_AD_20230428[Date_Month]<36),"24-36",
    MYK_AD_20230428[Date_Month]>36,"36+",
    BLANK()
)

 

The error in the formula is related to the usage of the AND function. The AND function requires a minimum of two arguments, but in the formula you provided, some of the AND functions have only one argument.

 

Let me know if you might need further assistance.

 


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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