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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
matrix_user
Helper III
Helper III

Calculated column & DAX for slicer issues.

Hi,

 

Is there anyone who can help? I am trying to work out how I could create the 'Desc' column below so that it can be used in a slicer. The fields pane shows that the 'Desc' column is somewhat a column created by DAX in a calculated column. I am assuming this because there is no SUM symbol like Index Dexc and Index has.

 

The 'Desc' column has been created from the 'Period' column.  For example, 'W1 2019' would be selected as 'W' in the slicer. '2021' would be 'Y' and 'Jan 2019' would be 'M'. See pic below.

 

matrix_user_0-1643328085157.png

 

The above pic are not from my pbix file I am working on. They are from online. I am trying to replicate this:

 

matrix_user_2-1643327833293.png

 

Thank you.

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I think you can try this DAX formula to achieve your requirement:

You can create the calculated column [Desc] like this:

Desc =

IF(

    NOT(ISERROR(VALUE(LEFT('Slicer'[Period]))+1)),"Y",

    IF(

        NOT(LEFT('Slicer'[Period],1) in {"Q","W"}),"M",

        LEFT('Slicer'[Period],1)))

 

And you can get what you want, like this:

vrobertqmsft_0-1643787458667.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I think you can try this DAX formula to achieve your requirement:

You can create the calculated column [Desc] like this:

Desc =

IF(

    NOT(ISERROR(VALUE(LEFT('Slicer'[Period]))+1)),"Y",

    IF(

        NOT(LEFT('Slicer'[Period],1) in {"Q","W"}),"M",

        LEFT('Slicer'[Period],1)))

 

And you can get what you want, like this:

vrobertqmsft_0-1643787458667.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

VahidDM
Super User
Super User

Hi @matrix_user 

 

Can you share a sample of your data table in a text format?

 

 

BTW, try this code to add a new column with dax:

 

New Column =
VAR _RW =
    RIGHT ( Table[Period], 1 )
RETURN
    IF ( _RW = "W", "W", IF ( _RW = 2, "Y", "M" ) )




 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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