Power BI - Is there a way to conditionally format a text column if it does NOT meet a criteria? - sql

as the title states, is there a way to conditionally format a text column if it does NOT meet a criteria - In Power BI?
i.e: Format a column's font colour if it is NOT "x".
e.g:
I want to format the following data (using the letter column) and highlight a, b and c (as they are not equal to x)
ID | code | letter
------------------
1 | 123 | a
2 | 345 | b
3 | 567 | x
4 | 789 | c
------------------

You can always create a measure to determine the desired highlight color for example, and use it, e.g. like this:
Measure = If(FIRSTNONBLANK('Table'[letter]; [letter]) = "x"; BLANK(); "#AABBCC")
See Color formatting by field value:
You can use a measure or a column that specifics a color, either using a text value or a hex code, to apply that color to the background of font color of a table or matrix visual. You can also create custom logic for a given field, and have that logic apply the desired color to the font or background.
You didn't mention what do you want to highlight and how. If the data will not be aggregated and show all rows in a table, you can calculate the highlighting color in conditional column in Power Query Editor, or computed column (DAX). If the highlighting rules will be applied on aggregated data, then you should use DAX measure.
If you want to highlight a cell, return the desired color. Otherwise return null in Power Query Editor, or BLANK() in DAX.

Related

Applying Cross Apply & String_split to column - SQL

I have data in the following format unfortunately I'm powerless to how the data comes in, the data looks like;
ID
Column X
1
I (a)Some Text (b)Some more Text (c) Text
2
1a Some Text b Some more text c
Is it possible to use Cross Apply and String split so data looks something like;
ID
Column X
1
(a) Some text
1
(b) Some more text
1
(c) Text
2
a Some text
2
b Some more Text
Ideally, the end goal once split will be to remove the a,b,c etc.
I'm using SQL Version; 2019 Dev

Value to table header in Pentaho

Hi I'm quite new in Pentaho Spoon and I have a problem:
I have a table like this:
model | type | color| q
--1---| --1-- | blue | 1
--1---| --2-- | blue | 2
--1---| --1-- | red | 1
--1---| --2-- | red | 3
--2---| --1-- | blue | 4
--2---| --2-- | blue | 5
And I would like to create a single table (to export in csv or excel) for each model grouped by type with the value of the group as header and as value the q value:
table-1.csv
type | blue | red
--1--| -1-- | -1-
--2--| -2-- | -3-
table-2.csv
type | blue
--1--| -4-
--2--| -5-
I tried with row denormalizer but nothing.
Any suggestion?
Typically it's helpful to see what you have done in order to offer help, but I know how counterintuitive the "help" on this step is.
Make sure you sort the rows on Model and Type before sending them to the denormalizer step. Then give this a try:
As for splitting the output into files, there are a few ways to handle that. Take a look at the Switch/Case step using the Model field.
Also, if you haven't found them already, take a look at the sample files that come with the PDI download. They should be in ...pdi-ce-6.1.0.1-196\data-integration\samples. They can be more helpful than the online documentation sometimes.
Row denormalizer can't be used here if number of colors is unknown, also, you can't define text output fields dynamically.
There are few ways that I can see without using java and js steps. One of them is based on the following idea: we can prepare rows with two columns:
Row Model
type|blue|red 1
1|1|1 1
2|2|3 1
type|blue 2
1|4 2
2|5 2
Then we can prepare filename for each row using Model field and then easily output all rows using text output where file name is taken from filename field. In this case all records will be exported into two files without additional efforts.
Here you can find sample transformation: copy-paste me into new transformation
Please note that it's a sample solution that works only with csv. Also it works only if you have the same number of colors for each type inside model. It's just a hint how to use spoon, it's not a complete solution.

VBA to find maximum value in a chart

I have a range of data columns A, B, and C. I have displayed as a line graph with B as the primary axis and C as the secondary axis. Column A is the category axis. I want to find the maximum value of column C and put a data callout on the point that is the maximum of column C and where column B occurs.
I know this sounds confusing. In this example, the maximum of Column C occurs at Point 27 (or 1.50% on the category axis). I would like a dot at point 27 for both Column B and C.
Column A is percentage from -5.00 to 10.00 incremented at .25%. Columns B and C are plotted against the change.
In the past I have done something similar, use a formula in column D to identify the largest number in Column C and B and make it a value high on your chart if the result is true.
Add Column D as a series to the chart.
Change the chart type on that series only to a scatter chart or something that puts points up there.
You can put a label on or simply put the amount showing above the plotted point.
You don't need VBA for this.
You might be interested to know I found a solution that works for me. First, I added columns D and E using the formula =IF(C2=MAX(C$2:C$62),C2,NA()) and =IF(C2=MAX(C$2:C$62),B2,NA()), this gave me the point on the graph for both lines B and C where B was maximum. I then formatted the graph so that these points had data callouts (a request from the client). Finally, I set columns D and E to have white font, to match the background so the appear invisible. I don't love this step, but I don't want the client to see the extra rows of #NA, etc.
The basic VBA for data callout is ActiveChart.FullSeriesCollection(5).Select
ActiveChart.SetElement (msoElementDataLabelCallout)
Where the series is 5 (column E) and I'm putting a data callout on the graphed point, which happens to be the maximum of column 3.

Mark accumulated values on a QlikView column if condition is fulfilled

I have a table in Qlikview with 2 columns:
A B
a 10
b 45
c 30
d 15
Based on this table, I have a formula with full acumulation defined as:
SUM(a)/SUM(TOTAL a)
As a result,
A B D
b 45 45/100=0.45
c 30 75/100=0.75
d 15 90/100=0.90
a 10 100/100=1
My question is. how do I mark in colour the values in column A that have on column D <=0.8)?
The challenge is that D is defined with full accumulation, but if I reference D in a formula, it doesn't consider the full accumulation!
I tried with defining a formula E=if(D>0.8,'Y','N') but this formula doesn't take the visible (accumulated) value for D unfortunately, instead it takes the D with no accumulation. If this worked, I would have tried to hide (not disable) E and reference it from the dimensions column of the table , Text colour option. Any ideas please?? Thanks
You can't get an expression column's value from within a dimension or it's properties, because the expression columns rely on the dimensions provided. It would create an endless loop. Your options are:
Apply your background colour to the expression columns, not the dimensions. This would actually make more sense as the accumulated values would have the colour, not the dimension.
When loading this specific table, have QlikView create a new column that contains the accumulated values of B. This would mean, however, that the order of your chart-table would need to be fixed for the accumulations to make any sense.
Use aggregation to create a temporary table and accumulate the values using RangeSum(). Note this will only accumulate properly if the table is ordered in Ascending order of Column A
=IF(Aggr(RangeSum(Above(Sum(B),0,10)),A)/100>0.8,
rgb(0,0,0),
rgb(255,0,0)
)

Highlighting Values in a Crystal Reports Crosstab based on sibling values

I have crosstab which has row columns indicating different classes, and then peoples names across the top.
| | Required | Person 1 | Person 2 | Person 3 |
| Class 1 | 8 6 | 1 6 | 3 6 | 4 6 |
| Class 2 | 6 2 | 3 2 | 2 2 | 1 2 |
Each field contains 2 values The first value is the number of hours spent in the class, the second field is the number of hours required for certification.
The Required field id my grand total summary.
In the cross tab expert the fields are defined as follows.
Rows:
Command.descr -> a field containing the class names
Columns:
Command.fullname -> a field containing students full names
Summarized Fields:
Sum of Command.evlength -> summation of all time spent in a given course
Max of #required -> this formula returns the number of required hours based on the course name
I am trying to highlight the field Sum of Command.evlength if it is greater than or equal to the value of Max of #required.
My solution was to perform background formatting. Right-Click on the Sum of Command.evlength field, select Format Field. Click the borders tab, check Background, and enter a formula.
The formula I was using is:
if CurrentFieldValue >= {#required} then color(152, 251, 152) else crNoColor
This is not the correct formula. My crosstab has been placed in the footer, which causes {#required} to contain the last value in the grid which in the above example is 2.
From my research I thought I would have to use GridRowColumnValue(row or column name) to access the value of {#required} in the crosstab, but I could not come up with the correct string to represent it.
Does anyone have a way for me to correctly perform this comparison?
Frustratingly I don't think you can use the highlighting expert to compare to a dynamic value. You could swap the columns round then add the following formulas:
To the max_of_required background colour:
whileprintingrecords;
global numbervar required_hrs := currentfieldvalue;
crNoColor;
To the sum_of_command.evlength background colour:
whileprintingrecords;
global numbervar required_hrs;
if currentfieldvalue >= required_hrs then
crRed
else
crNoColor;
I think there are a few other ways but i'm not as confident with those so start here.