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
Anonymous
Not applicable

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!

 

@Anonymous 

5 REPLIES 5
Anonymous
Not applicable

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

Hi @Anonymous ,

 

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

Hi @Anonymous ,

 

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.

v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

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.

 

amitchandak
Super User
Super User

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

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.