Show data by grouping values in a column - group-by

I'm working on a PowerBI project to analyze some alarm log data generated by one of our applications. For sake of brevity, this is what a typical log would look like if you get rid of all clutter.
TimeStamp,Unit,Alarm,Machine
2020/02/25 13:33:45,A,Error,M1
2020/02/25 13:33:46,B,Error,M1
2020/02/25 13:33:47,C,Serious Error,M2
2020/02/25 13:33:48,A,Warning,M4
2020/02/25 13:33:49,C,Information,M3
2020/02/25 13:33:50,B,Information,M1
2020/02/25 13:33:51,D,Warning,M1
2020/02/25 13:33:52,E,Error,M2
2020/02/25 13:33:53,A,Serious Error,M4
2020/02/25 13:33:54,C,Dead Serious Error,M5
2020/02/25 13:33:55,B,Serious Error,M2
2020/02/25 13:33:56,B,Warning,M1
2020/02/25 13:33:57,D,Information,M3
2020/02/25 13:33:58,A,Warning,M2
2020/02/25 13:33:59,C,Error,M1
2020/02/25 13:34:00,E,Error,M2
2020/02/25 13:34:01,C,Critical Error,M4
2020/02/25 13:34:02,A,Critical Error,M5
2020/02/25 13:34:03,B,Error,M4
2020/02/25 13:34:04,C,Warning,M2
In the designer, if I want to show alarms by count, I can simply create a column chart with Axis = Alarm and Value = Count of Alarm, which would give me the following.
Which is absolutely fine.
But what if I want to generate a similar chart, but alarms grouped by the alarm text. For example, suppose these are my groups.
Errors - Any alarm that contains the word 'error'.
Warnings - Any alarm that contains the word 'warning'.
Other - Everything else.
This would mean the above log would be grouped into 3 categories, and it should look like this.
I generated the above by manually creating another log file, which I don't want to do in my real project. How would I go about achieving this?
I know the GroupBy function exists in the Query Editor, but it doesn't seem to give me the results I need.
Edit
Note that in my real log there are hundreds (if not thousands) of different alarms, and I may also get daily logs from different places where each new log may potentially contain an alarm that wasn't there before. Unfortunately I don't have a full list of alarms across the board, so creating a static table with alarms grouped isn't an option.

You can create a calculated column either in the query editor or using DAX to group these and then use that calculated column instead of Alarm for your axis.
Here's an example of how you could do it with DAX:
Group =
SWITCH (
TRUE (),
CONTAINSSTRING ( 'Table'[Alarm], "Error" ), "Errors",
CONTAINSSTRING ( 'Table'[Alarm], "Warning" ), "Warnings",
"Other"
)
This SWITCH returns the value for the first line that equals TRUE(). More details on this here:
DAX – The Diabolical Genius of “SWITCH TRUE”
You also can do it with a custom column in the query editor using M code like this:
if Text.Contains([Alarm], "Error") then "Errors"
else if Text.Contains([Alarm], "Warning") then "Warnings"
else "Other"
Note: M code is case-sensitive whereas DAX is not.

Related

EPi find get all variants if search hit on product

A EPi find question coming up, We have WebProducts and WebVariants and when showing a simple product listing on the category page I'm showing the following result correctly
If a WebProduct doesn't have any variants - show the WebProduct on the result
If a WebProduct has variants - show the WebVariants and hide the WebProduct
But when I'm trying to use the same functionality for the site-search it gets complicated.
The WebProduct has a property named Brand while the WebVariants doesn't have that property. So when I search for "My brand" and I get a hit on a WebProduct that has WebVariants, it won't show the WebProduct because point 2 is true in that case.
I on the other hand don't want to show the product, but I want to get the variants for that product... It might sound confusing :grimacing:
I'll add a code snippet of the code that makes point 1 and 2 to work.
.SearchAndFilterFor(q)
.Filter(x =>
(x.MatchType(typeof(WebVariant))) |
(x.MatchType(typeof(WebProduct)) & ((WebProduct)x).HasVariants().Match(false)))```
I would say that you have a couple of options to choose from.
Either:
1: Change the way your variants are indexed so that they include some of the key info (in this case brand) that they currently lack and as such, appear in the search results.
OR
2: Just do the search for WebProduct and then loop through those results afterward to do the processing for ones that do/don't have variants.

Prestashop 1.7 - filtering not working, showing empty results

I have got a problem on my store (still under development) - http://condesign.pl/officina . It's all about filtering products, for example here: http://condesign.pl/officina/pl/521-akcesoria-ze-skory . All the attributes on the left are being displayed correctly, with numbers of products in brackets, but when You click on any filter (like size or color), the list of results is empty.
Help please!
Try yo do the exact same thing with the default theme of Prestahsop. Because this looks like a theme issue.
This is very large bug in ps_facetedsearch module... You can't do anything with this. You must wait for fix. https://github.com/PrestaShop/PrestaShop/issues/9684 here is list of bugs in module.
It was my mistake - this module uses table ps_stock_available. I was migrating data from previous store to this one (only in phpmyadmin, not panel, because of very different structures), and I didn't know about this table. So it was about my missing data.

Adding and removing Measures dynamically in sapui5 VizFrame

I would like to change Measures dynamically in my VizFrame like in ChartDemo App from sapui5 docs [link below].
https://sapui5.netweaver.ondemand.com/test-resources/sap/viz/demokit/chartdemo/index.html
So when I click to one of my five checkboxes the proper Measure will be added or removed in case of unchecking.
I have one json from which I get data.
I've tried with this code:
if(oCheckBox.getSelected()){
oVizFrame.removeFeed(feedValuesAxis);
feedValuesAxis.setValues("ValueFromJSON");
oVizFrame.addFeed(feedValuesAxis);
}
But it causes error:
[50005] - valueAxis : does not meet the minimum or maximum number of
feeds definition.
I am using SAP UI5 version 1.28.
I have one VizFrame, one Dataset with all Measures and two FeedItem one for values and one for Dimension.
I guess I have to create a binding, right? But how should I do it? Thanks a lot for any pieces of advice.
Simply, I have missed array when putting value into setValues() method.
So the answer is:
feedValuesAxis.setValues(["ValueFromJSON"]);

Update Fields On Form Based On Entries

I have a bound form that has roughly 8 text boxes on it. I am in some instances needing to subtract the value from textbox2 from the value in textbox1. For example, my set-up is like so:
lblProfit lblOTBilled
txtProfit txtOTBilled
txtProfit is where the profit amount would be input, BUT if there is any OT billed, then I would need to use this formula
txtProfit = txtProfit - txtOTBilled
My issue is that both txtProfit and txtOTBilled are bound fields so I am not quite sure how to go about setting this up.
In Access 2013 how would I do something like this?
You will need an additional textbox:
txtProfitCalculated
and control source for this:
=[txtProfit]-Nz([txtOTBilled],0)

Visualization Tableau - Remove an option from a filter

This is the link of my visualization: My dashboard
In the tab "Cursos por ciclo", I would like to know how to remove the option "PTJE.TOTAL" from the filter "CURSO".
You can do this by creating a new calculated field.
Right click on CURSO and select "create calculated field" then use this formula:
IF left([CURSO], 4) <> "PTJE" THEN [CURSO] END
Basically, this means: if the value does not start with "PTJE" then include it.
Then use the new calculated field as a filter, you will see that it does not include the "PTJE. TOTAL" value (it has been replaced with nulls now). So when you apply a quick filter the "PTJE. TOTAL" value won't appear.
Note: Normally I'd use something simpler like:
IF [CURSO] <> "PTJE. TOTAL" THEN [CURSO] END
but that is not working with your data for some reason.
Also, you can read more about calculated fields in Tableau here:
http://onlinehelp.tableausoftware.com/v6.1/public/online/en-us/i181523.html