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
dtango9
Helper II
Helper II

Help with DAX Statement

Hi,

I'm new to Power BI and am hoping someone can help.  I'm looking to create a statement with the following criteria:


- Condition 1 = "Type A"  AND  Condition 2 = "Type B"

- Date Field # 1 = In the past

- Date Field # 2 = Today and in the future

 

Any help is greatly appreciated 🙂

1 ACCEPTED SOLUTION

@dtango9 

 

Try something similar to this

 

Trial Offer =
IF (
    ( new_contract[subscription_type] = "Contract"
        || new_contract[new_dear] = "OFFER" )
        && (
            new_contract[subscriptioncancellationreason]
                <= TODAY ()
                && new_contract[new_enddate]
                    >= TODAY ()
        ),
    "Yes",
    "No"
)

 

Without seeing your data model it is difficult to tell you the exact DAX. Please modify it based on your requirement.

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

View solution in original post

6 REPLIES 6
nandukrishnavs
Super User
Super User

@dtango9 

 

You could use IF(), AND() , TODAY()

 

IF(<logical_test>,<value_if_true>[, <value_if_false>])
AND(<logical1>,<logical2>)

 

Please refer to this link for more understanding.

https://www.tutorialgateway.org/power-bi-dax-logical-functions/

 

If you are still confused, then provide your sample tables.

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

Thanks!   Here are my sample tables - I'm still not getting it to work.

 

  • new_contract[subscription_type] = "Contract" AND new_contract[new_deal] = "OFFER"
  • new_contract[new_subscriptioncancellationreason] is expired
  • new_contract[new_enddate] is today or in the future

@dtango9  please provide a sample table and expected output. Are you trying to create a calculated column or measure?


Regards,
Nandu Krishna

I am looking to create a calculated column that returns True or False/Yes or No if all the criteria is met.

 

So far I have:

Trial Offer = IF(new_contract[subscription_type] = "Contract", new_contract[new_dear] = "OFFER")
 
But that isn't working because I believe I need an IF AND statement.  I also need to include new_contract[subscriptioncancellationreason] = <= TODAY() and the date criteria new_contract[new_enddate] >= TODAY()

@dtango9 

 

Try something similar to this

 

Trial Offer =
IF (
    ( new_contract[subscription_type] = "Contract"
        || new_contract[new_dear] = "OFFER" )
        && (
            new_contract[subscriptioncancellationreason]
                <= TODAY ()
                && new_contract[new_enddate]
                    >= TODAY ()
        ),
    "Yes",
    "No"
)

 

Without seeing your data model it is difficult to tell you the exact DAX. Please modify it based on your requirement.

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

This is excellent.  Thank you so much for your help 🙂

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.