cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Prabha45
Helper II
Helper II

DAX - Selected value

Hi
I wrote a measure where if is January is selected measure shows 1, february 2, so on till december.
Measure = switch(selectedvalue
                              (dim_table[month_name]),
                               "January",1,
                                "February",2)
Is it possible , if both January and February are selected, measure should show 1,2. If January,February and March are selected measure should show 1,2,3.

Thankyou

11 REPLIES 11
tamerj1
Super User
Super User

Hi @Prabha45 

if the month name column is coming from a date table the you can try. 

CONCATENATEX ( VALUES ( 'Date'[Date].[Month] ), [Month], "," )

However, the following shall work in all scenarios 

CONCATENATEX (

VALUES ( 'Table'[Month] ),

SWITCH (

[Month],

"January", 1,

"February", 2,

etc. 

),

","

)

 

Thanks that worked. I need the measure to be in integer format, but it is in Text format. I used convert to change it to integer then the output changed to 123.

@Prabha45 

Cannot have an integer with delimiter. What exactly are you trying to achieve?

I need to trigger a function app with the filters selected in Power BI as input for the function app. It has month parameter which accepts inputs as 1 or 1,2 or 1,2,3. If I use the above measure( text format) it takes the values as "1,2,3". So, I converted it to integer then it took input as 123. 

@Prabha45 

So with CONVERT you got your desired outcome? Or you still need further support? If so please clarify further perhaps with some examples and/or screenshots. 

No. If I use convert, the output of the measure changes to 123. With 123 as input, I can't trigger the function app.
If I don't use convert, the measure output is 1,2,3. when I pass this as input it takes as "1,2,3".

@Prabha45 

I hope you realize that there is no possibility that I have any idea what function app is. I don't see what you see. I have no access to your report so please treat me as complete blind when explaining to me ☺️

FreemanZ
Super User
Super User

hi @Prabha45 

1) try to add a column like:

month_number = 
SWITCH(
    [month_name],
    "January", 1,
    "February", 2,
    "March", 3,
    "April", 4,
    "May", 5,
    "June", 6,
    "July", 7,
    "August", 8,
    "September", 9,
    "October", 10,
    "November", 11,
    12
)

 

2) then plot a measure like this:

Measure = 
CONCATENATEX(
    TableName,
    TableName[month_number],
    ","
)

 

it worked like:

FreemanZ_0-1677738070036.png

FreemanZ_1-1677738088895.png

 

Thanks that worked. But, the measure is in Text format. I used convert to change it to integer then the output changed to 123.

hi @Prabha45 

why change to integer?

I need to trigger a function app with the filters selected in Power BI as input for the function app. It has month parameter which accepts inputs as 1 or 1,2 or 1,2,3. If I use the above measure( text format) it takes the values as "1,2,3". So, I converted it to integer then it took input as 123. 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors