Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi there,
I'm using Direct Query and want to create a slicer / report based on the left 2 characters of a column.
Example source table:
Code Claim
AZ12 X
AB123 X1
AZ23 X3
Requested Report:
Left 2 Code Amount Claims
AZ 2
AB 1
I'm using the following DAX for left 2 characters. When I get rid of the column Code, also the Left 2 Code measure goes empty. Any tips on solving this? I cannot add a column because of direct query.
Selected 2 character =
var selected= if(HASONEVALUE('Table'[Column]),VALUES('Table'[Column]),BLANK())
return
If(selected<>BLANK(),LEFT(selected,2))
Solved! Go to Solution.
@Anonymous , if it is a new column simply use
LEFT('Table'[Column],2)
Hi @Anonymous ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it.
Best Regards,
Eyelyn Qin
Hi @Anonymous ,
According to the official document, HASONEVALUE() returns TRUE when the context for columnName has been filtered down to one distinct value only. Otherwise is FALSE.
In addition, calculated columns could not be dynamic that means values won't change according to the user selection. So It's not appropriate to use HASONEVALUE().
Please take a look at the below screenshot to understand the difference between Column and Measure.
In summary, as @amitchandak suggest , please just use LEFT() function directly.
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 65 | |
| 31 | |
| 28 | |
| 24 |