Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have calculated a measure (in DAX), the measure Main Code extrct the first letter from a column table.
I need this measure in a filter. I think this formula can be simplify...
I need to do everything in DAX, i can't edit the original dataset
Solved! Go to Solution.
Hi @Giulia997 ,
You can modify your formula like below:
Main Code1 =
VAR __MAX_VALUES_TO_SHOW = 1
VAR __VALUES_TO_SHOW =
TOPN (
__MAX_VALUES_TO_SHOW,
VALUES ( 'DIM_DOWNTIME'[Downtime Code] ),
LEFT ( 'DIM_DOWNTIME'[Downtime Code], 1 ), ASC
)
VAR __FIRST_LETTERS =
CONCATENATEX (
__VALUES_TO_SHOW,
LEFT ( 'DIM_DOWNTIME'[Downtime Code], 1 ),
", "
)
RETURN
IF (
DISTINCTCOUNT ( 'DIM_DOWNTIME'[Downtime Code] ) > __MAX_VALUES_TO_SHOW,
__FIRST_LETTERS & ", ecc.",
__FIRST_LETTERS
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Giulia997 ,
You can modify your formula like below:
Main Code1 =
VAR __MAX_VALUES_TO_SHOW = 1
VAR __VALUES_TO_SHOW =
TOPN (
__MAX_VALUES_TO_SHOW,
VALUES ( 'DIM_DOWNTIME'[Downtime Code] ),
LEFT ( 'DIM_DOWNTIME'[Downtime Code], 1 ), ASC
)
VAR __FIRST_LETTERS =
CONCATENATEX (
__VALUES_TO_SHOW,
LEFT ( 'DIM_DOWNTIME'[Downtime Code], 1 ),
", "
)
RETURN
IF (
DISTINCTCOUNT ( 'DIM_DOWNTIME'[Downtime Code] ) > __MAX_VALUES_TO_SHOW,
__FIRST_LETTERS & ", ecc.",
__FIRST_LETTERS
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Giulia997 , Try this
Main Code =
VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('DIM_DOWNTIME'[Downtime Code])
VAR __MAX_VALUES_TO_SHOW = 1
RETURN
IF(
__DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW,
CONCATENATE(
CONCATENATEX(
TOPN(
__MAX_VALUES_TO_SHOW,
VALUES('DIM_DOWNTIME'[Downtime Code]),
LEFT('DIM_DOWNTIME'[Downtime Code], 1),
ASC
),
LEFT('DIM_DOWNTIME'[Downtime Code], 1),
", "
),
", ecc."
),
CONCATENATEX(
VALUES('DIM_DOWNTIME'[Downtime Code]),
LEFT('DIM_DOWNTIME'[Downtime Code], 1),
", "
)
)
Proud to be a Super User! |
|
I have this result
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
6 |