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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
bonjourposte
Advocate III
Advocate III

Singling out certain text values in dax- birthday money

I've got a column of about 20 people and their birthdays, and I'm creating a DAX measure specifically for the nieces and nephews who will get money for their birthday.  Every birthday, they will get $5 plus their age.  

 

I'm trying to say, IF [person] = "tanya", "bobby", "sarah", "troy", then [Current Age] + $5.  How do you write that in DAX?  Is that a switch statement?  

Thanks!

1 ACCEPTED SOLUTION
bonjourposte
Advocate III
Advocate III

Thanks so much for your responses, guys.  I ended up using a SWITCH statement: 

Birthday Money =
    SWITCH(
        MAX(
    'Important Birthdays'[Person]),
    "Tanya", MAXX('Important Birthdays',[AgeToBeThisYear]) + 5,
    "Bobby", MAXX('Important Birthdays', [AgeToBeThisYear]) +5,
    "Sarah", MAXX('Important Birthdays', [AgeToBeThisYear]) +5,
    "Troy", MAXX('Important Birthdays', [AgeToBeThisYear]) +5,
    0
    )

View solution in original post

3 REPLIES 3
bonjourposte
Advocate III
Advocate III

Thanks so much for your responses, guys.  I ended up using a SWITCH statement: 

Birthday Money =
    SWITCH(
        MAX(
    'Important Birthdays'[Person]),
    "Tanya", MAXX('Important Birthdays',[AgeToBeThisYear]) + 5,
    "Bobby", MAXX('Important Birthdays', [AgeToBeThisYear]) +5,
    "Sarah", MAXX('Important Birthdays', [AgeToBeThisYear]) +5,
    "Troy", MAXX('Important Birthdays', [AgeToBeThisYear]) +5,
    0
    )
Ritaf1983
Super User
Super User

Hi @bonjourposte 
If the goal is a calculated column you can use this formula :

Column = IF([name] in {"tanya", "bobby", "sarah", "troy"},[age]+5,[age])
Ritaf1983_0-1722219562057.png

If you need the measure :

Measure_ =
SUMX(
    SUMMARIZE(
        'Table',
        'Table'[name],
        "Sum",
        IF(
            'Table'[name] IN {"tanya", "bobby", "sarah", "troy"},
            SUM('Table'[age]) + 5,
            SUM('Table'[age])
        )
    ),
    [Sum]
)
Ritaf1983_1-1722219615117.png

Pbix with the example is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Shravan133
Solution Sage
Solution Sage

try this:

Birthday Amount =
VAR PersonList = {"tanya", "bobby", "sarah", "troy"}
VAR CurrentAge = [Current Age] -- Replace [Current Age] with your actual column name

RETURN
IF (
[Person] IN PersonList,
CurrentAge + 5,
BLANK() -- This will return blank if the person is not in the list
)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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