cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

How can I get SWITCH to result in a field that is a text (Month Name)?

Hello All:

 

I have a table that reads like this 

 

YearMaxMaxPeriodMinMinPeriod
2018234.52June 2018112.34October 2018
2019573.34September 2019352.35June 2019

 

I've written a switch statement that works perfectly to give me the Min and Min and Max, but for a seperate card, how can I get write another Switch to return the associated Period fields?

 

I can't seem to figure out any DAX functions that will allow me to return a field that is a text format... and all the youtube examples show people typing a static string in quotes

 

Please let me know if this is not clear enough.

 

Thank You!

 

@VThai81 

5 REPLIES 5
Highlighted
Super User IV
Super User IV

Re: How can I get SWITCH to result in a field that is a text (Month Name)?

Not very clear. But let say if you get max date

 

Period = format(max(date[date]),"MMMM-YYYY")

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Support
Community Support

Re: How can I get SWITCH to result in a field that is a text (Month Name)?

Hi @A_Ali ,

 

Not quite sure what you want to return. In DAX, all strings need to be double quoted.

Measure 4 = 
SWITCH(
    TRUE(),
    MAX('Sales 2015'[Month]) = "January", "JAN",
    "ss"
)

 

Maybe you can give me a sample data and tell me what you want to return, I will try to write the DAX formula.

 

Best regards,
Lionel Chen

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

 

Highlighted
Advocate I
Advocate I

Re: How can I get SWITCH to result in a field that is a text (Month Name)?

Ok, guys. Thanks for the help, but it looks like I made a silly mistake and got it to work when i fixed it.

 

I was only fixing the first set of criteria in my switch statement, but had errors later on  in the formula that I (very wrongly) assumed would not affect the result as long as i didn't select the values in my SELECTEDVALUES portion of my expression. Turns out, the entire measure doesn't work if a single part of it has an error...

 

Sorry for the runaround and thanks for replying

Highlighted
Community Support
Community Support

Re: How can I get SWITCH to result in a field that is a text (Month Name)?

Hi @A_Ali ,

 

For the usage of the DAX functions, you can refer to the following official documents:

https://docs.microsoft.com/en-us/dax/switch-function-dax 

 

Best regards,
Lionel Chen

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

Highlighted
Community Support
Community Support

Re: How can I get SWITCH to result in a field that is a text (Month Name)?

Hi @A_Ali ,

 

If your problem has been solved, please consider Accept it as the solution to help the other members find it more quickly.

 

Best regards,

Lionel Chen

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors