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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
yogita
Frequent Visitor

Power bi variable

Hi All,

 

I am trying to edit a quick measure that I have created. However, I am tryin to edit to include one more if condition - If(__DISTINCT_VALUES_COUNT is blank then say"All Job Roles" else execute the below code. 


VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('DEMO'[Job Role])
VAR __MAX_VALUES_TO_SHOW = 5
RETURN
IF(
__DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW,
CONCATENATE(
CONCATENATEX(
TOPN(
__MAX_VALUES_TO_SHOW,
VALUES('DEMO'[Job Role]),
'DEMO'[Job Role],
ASC
),
'DEMO'[Job Role],
", ",
'DEMO'[Job Role],
ASC
),
", etc."
),
CONCATENATEX(
VALUES('DEMO'[Job Role]),
'DEMO'[Job Role],
", ",
'DEMO'[Job Role],
ASC
)
)

 

However I am not able to add this condition(If(__DISTINCT_VALUES_COUNT is blank then say"All Job Roles"). I am using this in dynamic title. When the Job role slicer is selected All or no selection is made , then show "All Job role" else show the selected role in the dynamic title. Hope I am clear. Appreciate your help on this. 

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi @yogita 

 

Can you provide some of the example data? As well as being the desired output, you can show it with a picture.

 

Best Regards

truptis
Community Champion
Community Champion

Hi @yogita , try using this:

Result= 

VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('DEMO'[Job Role])

VAR __MAX_VALUES_TO_SHOW = 5

Var new_variable=

IF(

__DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW,

CONCATENATE(

CONCATENATEX(

TOPN(

__MAX_VALUES_TO_SHOW,

VALUES('DEMO'[Job Role]),

'DEMO'[Job Role],

ASC

),

'DEMO'[Job Role],

", ",

'DEMO'[Job Role],

ASC

),

", etc."

),

CONCATENATEX(

VALUES('DEMO'[Job Role]),

'DEMO'[Job Role],

", ",

'DEMO'[Job Role],

ASC

)

)

 

Return 

If(ISBLank(__DISTINCT_VALUES_COUNT), "All job roles" , new_variable) 

 

 

@yogita -> please hit the thumbs up & mark it as a solution if it helps you. Thank you.

Hi Truptis, Thanks for your help. But this is not working.  Because the slicer is set on Select All, I donot think that __DISTINCT_VALUES_COUNT will be blank.  

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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