Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I have data from Power Bi dataset, I need to create a measure using if then else for a string variable"regions". I basically need to create a measure(since I cannot create a new column) which would combine some regions and rename some regions. Both if and switch statements are unable to identify by col("Cannot find name"). I think I need to summaries it.
Just for testing, I used count for this field, powerbi identifies it but I need something to work on text fields.
@Anonymous , you need to use min , max or firstnonblank or lastnonblank or dimension value
example masure
color =
switch ( true(),
FIRSTNONBLANK(Table[commodity],"NA") ="commodity1" && sum(Table[Value]) >500,"lightgreen",
FIRSTNONBLANK(Table[commodity],"NA") ="commodity2" && sum(Table[Value]) >1000,"lightgreen",
/// Add more conditions
"red"
)
measure =
switch ( true(),
max(Table[region]) ="R1" , [Mea1],
max(Table[region]) ="R2", [Mea2],
/// Add more conditions
[Mea3]
)
also refer
https://www.daxpatterns.com/dynamic-segmentation/
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization
HI @Anonymous ,
Not able to understand your query. Please share sample data along with expected output to understand your question here.
Thanks,
Pragati
@Anonymous If I understand correctly, use MAX or MIN as your aggregation. Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
Dear @Anonymous
Can you share some dummy data (3-4 rows ) and expected output
,You can use excel to show this , and just paste that things from excel in post section.
I will write and send you measure 👍
Regards
Thakur Sujit
Have field, "productname" values as ABC, AB,AA, etc. Need to convert values in a new measure like ABC=AB1, AB=AB2. Trying to use switch or IF, but field "productname" is not being identified
@Anonymous
For row context and filter context understanding = https://youtu.be/xV-KwuSDFMQ
Keep learning my friend
Dear @Anonymous
You are having such issues because you didn't have included Aggregation function before your field .
I would suggest you , if you want to change values like ABC=AB1, AB=AB2.
Use a calculated column, it will be more easy and helpful .
Use this
Column = Switch (
True(),
[Product name] = "ABC" , "AB1",
[Product name] = "AB" ,"AB2",
"Else condition value "
)
Or if you are adhered using measure let me tell you my friend , for using any field in measure you must use aggregation function before it to tell power bi that from which rows you want calculation to happen.
But as column works most of the time in row context hence no aggregation function will be required in calculated columns.
I hope you understand .
If any doubt let me know .
I do expect kudos to keep me motivated !!
If this post helped you to solve your problem then please accept it as solution.
Regards
Thakur Sujit
Thankyou so much. I have data from powerbi datasets so I cannot create any new columns. What aggregation should I use for this string variable?
@Anonymous very confusing what you are trying to do here. You need to provide some sample data and expected output. Read this post to get your answer quickly.
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |