Oracle APEX RDS Tabs on multiple rows instead of scroll - oracle-apex

Is there any way to have tabs show as sets of rows, rather than 'scrolling' through them?
For instance, If I have my app split into two regions, with data on the left, and sections of meta-data on the right, if I have more than 4 tabs on the right, it starts to scroll. I'd like to be able to have them on multiple rows. Sort of like:
Section 1 | Section 2
Main data area | Tab 1 | Tab 2 | Tab 3
| Tab 4 | Tab 5 |

Related

PowerBI generate table from another table

Good morning,
I have the following table with RAW data:
USER | YEAR | I1 | G1 | I2 | G2 | I3 | G3
A | 2021 | 1 | 3 | 4 | 2 | 5 | 1
B | 2021 | 3 | 2 | 1 | 2 | 4 | 1
And I need to create from this table another table, generating 3 new lines per Table A line.
USER | YEAR | # | I | G
A | 2021 | 1 | 1 | 3
A | 2021 | 2 | 4 | 2
A | 2021 | 3 | 5 | 1
B | 2021 | 1 | 3 | 2
B | 2021 | 2 | 1 | 2
B | 2021 | 3 | 4 | 1
I cannot find how to do it in PowerBI. I worked with other languages in which I would face this by extracting 3 times the information from the first table (in the first extraction I would select the I1 and G1, in the second one the I2 and G2 and in the third one the I3 and G3) and I would append it. However, I am not able to find in google how to do this with DAX.
Can anyone help me?
Thank you so much,
I believe you are asking how to do this with DAX simply because this is the only way you've heard. In Power BI, you should do such transformation using M, i.e. in Power Query Editor.
The format of the data is not optimal, so you will need to transform it a bit more. So open Power Query Editor by clicking on Transform data button in the ribbon, and then make a copy of your table by right-clicking it in the list and select Duplicate. Delete I1, I2 and I3 columns from one of the tables, and delete G1, G2 and G3 columns from the other. In each of the tables, select all three Ix/Gx columns and click Transform -> Unpivot Columns. After this step, the tables should looks like this:
Rename Values columns to I and G, and in each of the tables split the Attribute column by right clicking the column title and selecting Split column -> By number of characters... like this:
Rename the column with the numeric value (Attribute.2) to # in both tables and remove the other one (Attribute.1). After this stage, you should have two tables with the first 3 columns the same, and I and G columns containing the numeric values:
Now you must merge these two tables together, by clicking the drop down of Home -> Merge Queries and selecting Merge Queries as New, then select your two tables and select USER, YEAR and # columns as keys in both lists:
Expand the table by clicking the button in the columns title:
And leave only the other value, so at the end (after renaming the columns) you will get the desired result:

How to plot multiple measures on a line chart with shared axis and legend

I have two line plots that come from a different columns in measurement formulas but both share the time axis.
This is the first plot:
The second one:
In this case the second plot is just a scaled version of the first one, but the principle remains the same, I´m not able to just drag and drop the values from both measurements into the same "valores" box, it just iverwrites:
How can I plot this two measurements on the same box?
Something like the stacked areas plot but without the offset.
This is my data:
And the expresion fot the measurements I´m using:
Medida = CALCULATE(sum(test_data[Percentage_By_Class]);filter(test_data;test_data[Date]=max(test_data[Date]));
ALLEXCEPT(test_data;test_data[Score]))/ CALCULATE(sum(test_data[Percentage_By_Class]);
filter(all(test_data);test_data[Date]=max(test_data[Date])))
Medida2 = CALCULATE(sum(test_data[Percentage_By_Class]);filter(test_data;test_data[Date]=max(test_data[Date]));
ALLEXCEPT(test_data;test_data[Score]))/ CALCULATE(1.3*sum(test_data[Percentage_By_Class]);
filter(all(test_data);test_data[Date]=max(test_data[Date])))
And a google drive link to download the used data in CSV format:
https://drive.google.com/file/d/1dEdUwwofv1OQ9rOGQMuyfYKO9_YJDTcl/view?usp=sharing
I don't think there's a nice built-in way to do this, but here's a possible workaround:
Create a new table for the legend which will be the Cartesian product of scores and measures.
Legend =
ADDCOLUMNS(
CROSSJOIN(VALUES(test_data[Score]), {1,2}),
"Legend", [Score] & [Value]
)
This table should like this:
| Score | Value | Legend |
|-------|-------|--------|
| A | 1 | A1 |
| C | 1 | C1 |
| B | 1 | B1 |
| A | 2 | A2 |
| C | 2 | C2 |
| B | 2 | B2 |
Now create a combined measure that switches between [Medida] and [Medida2]:
Combo =
IF(
SELECTEDVALUE(Legend[Value]) = 1,
CALCULATE([Medida], test_data[Score] in VALUES(Legend[Score])),
CALCULATE([Medida2], test_data[Score] in VALUES(Legend[Score]))
)
Then if you put Legend in the legend box and Combo in the values box, you should get a chart like this:
You can change the colors too if you want to visually group the lines.

Sum distinct values for first occurance in Power BI

In Power BI I have some duplicate entries in my data that only have 1 column that is different, this is a "details" column.
Name | Value | Details
Item 1 | 10 | Feature 1
Item 1 | 10 | Feature 2
Item 2 | 15 | Feature 1
Item 3 | 7 | Feature 1
Item 3 | 7 | Feature 2
Item 3 | 7 | Feature 3
I realize this is an issue with the data structure, but it cannot be changed.
Basically, when I sum up my Value column on a Power BI card, I only want it to sum for each unique name, so in this case:
Total = 10 + 15 + 7
I will be using the details in a matrix, so I cannot simply remove the duplicates from within the Query Editor.
Is there any way I can filter this with a DAX formula? Just summing the first occurrence of an item?
You can create a measure as follows:
Total = SUMX(DISTINCT(Data[Name]), FIRSTNONBLANK(Data[Value], 0))
It will return the first non-blank Value for all distinct Name and sum it up.
Results:
This must help
Table = SUMMARIZE(Sheet2,Sheet2[Item],"Sales Quantity",SUM(Sheet2[Sales Quantiy]),"Purchase Quantity",CALCULATE(SUMX(DISTINCT(Sheet2[Purchase Quantity]),FIRSTNONBLANK(Sheet2[Purchase Quantity],0))))

Generating variable

I have a dataset in which variables are like the image
I want to produce a table for serogroup and all antibiotics[penicillin-tetracycline]. Antibiotics have value label ("Sensitive" "Resistant").
Here I only consider "Resistant" value.
I have tried following code:
gen All_antibiotic =1 if penicillin=="Resistant"
replace All_antibiotic =2 if ampicillin=="Resistant"
.
.
tab All_antibiotic serogroup
But it did not give complete table.
There are various difficulties here:
You don't provide a reproducible example, in that you don't provide a data example we can use. See this page on minimal examples.
You don't make clear what would be the rows, columns and cells of the table.
You are confusing string values and value labels. "Resistant" is a string value, not a value label.
The question title doesn't really indicate the problem.
This may help. In your case you would need rename before you could use reshape.
clear
input id group str4(y1 y2 y3)
1 1 frog frog toad
2 1 frog toad toad
3 1 toad toad toad
4 2 frog frog frog
5 2 frog frog toad
6 2 frog toad toad
end
preserve
reshape long y, i(id) j(which)
describe
tab group y
| y
group | frog toad | Total
-----------+----------------------+----------
1 | 3 6 | 9
2 | 6 3 | 9
-----------+----------------------+----------
Total | 9 9 | 18
restore

SUMIF based on array

Not sure if I'm overlooking something but I can't seem to find an answer for this. I have two sheets:
Sheet 1
country | cost
---------------------
DE | 5
FR | 4
US | 3
MX | 2
AT | 1
Sheet 2
region | country
---------------------
EU | DE
EU | FR
AM | US
AM | MX
EU | AT
What I want is the sum of cost of all European Countries. In the past I simply used a column C with VLOOKUP for the region in Sheet 1 and then SUMIF'd this data. I'd like to avoid this, because the volume of data in Sheet 1 is huge and dynamic.
I could of course use
=FILTER(Sheet2!country, Sheet2!region="EU")
which would return an array of {"DE", "AT", "FR"}, but I cannot use
=SUMIF(Sheet1!cost, Sheet1!country=FILTER(Sheet2!country, Sheet2!region="EU"))
Is there an alternative to this?
Maybe you are looking for something like this:
=ArrayFormula(sum(sumif(A:A,filter(Sheet2!B:B,Sheet2!A:A="EU"),B:B)))
Then, replace the VLOOKUP with an INDEX MATCH,
=IFERROR(INDEX(Sheet2!$A$2:A$6, MATCH(A3, Sheet2!$B$2:B$6, 0)))
where col B in sheet 2 are the countries, and col A the region
In order to use VLOOKUP you would have to change the lay-out of sheet 2 so that it has country in col 1 and region in col 2
Then you can use VLOOKUP in col C of first sheet
=VLOOKUP(A3, Sheet4!$A$2:$B$6, 2)
Drag down as far as needed
And for the sumif:
=sumif(C3:C7, "EU", B3:B7)