I'd likt to ask the way of grouping caategories. I knew that can use the Group function.
But my question is about duplicated values.
For example, There's column A,B,C,D,E in one table, but i want to make the bar graph as A, B&C, C&D ,E
Thank you for your time :)
I tried use group function, but since I group the Column B&C, It is not allow to gorup as C&D.
Create the following calculated table that contains your grouping logic
Groups =
DATATABLE(
"Group", STRING,
"Category", STRING,
{
{"A", "A"},
{"B & C", "B"},
{"B & C", "C"},
{"C & D", "C"},
{"C & D", "D"},
{"E", "E"}
}
)
Next you create a one-to-many relation between the Categories with the filter direction set to "Both" (bi-directional)
Finally you can create your visuals with the overlapping grouping
Related
I have multiple simple calculated measures, which I would like to combine into categories, so that one could use this "category measure" in matrix visual.
Each measure basically counts data with some filter(s), like:
Blue =
CALCULATE(
COUNT(data[Full name]),
FILTER(data, data[White/Blue] = "Blue")
)
My attempt to this, was to create a table for measures categories, and then measure indexed accordingly.
Table:
Measures categories =
DATATABLE (
"Category", STRING,
"Sub-Category", STRING,
"Index", INTEGER,
{
{ "Direct/Indirect", "Direct", 1},
{ "Direct/Indirect", "Indirect", 2},
{ "White/Blue", "White", 3},
{ "White/Blue", "Blue", 4}
}
)
Measure:
Categories measure =
VAR SelectedMeasure_ =
SELECTEDVALUE('Measures categories'[Index])
RETURN
IF(HASONEVALUE('Measures categories'[Index]),
SWITCH(
SelectedMeasure_,
1, [Direct],
2, [Indirect],
3, [White],
4, [Blue]
)
)
This seems to work fine, however I'm missing Totals in Matrix visual, how do I get sum of measures per category/subcategory and total? I can workaround this by adding additional Total fields with corresponding sums, but there must be a better way.
One possible solution, is to create another measure, which sums value of Categories measure.
Your hasonevalue() looks like the problem. You need to rethink your approach to use values() but hard to advise further without a .pbix or full sample data to work from.
I have following task for my Google spreadsheet: JOIN strings in all cells that are to the right of certain id.
To phrase it differently: SELECT A, JOIN(',', B) GROUP BY A, WHERE A = myid; if JOIN was an aggregation function.
Or in other words: =JOIN(',', VLOOKUP(A:B, myid, 0)) if VLOOKUP could return all occurences, not just first one.
One picture better than of 1000 words:
Is this possible with Google Spreadsheets?
I believe you could use the FILTER function instead of VLOOKUP to filter a range based on an ID and then JOIN the returned range.
The documentation for FILTER is here: https://support.google.com/docs/answer/3093197
For example:
You put =UNIQUE($A:$A) in D2 to get all the IDs.
Then in E2 you put =IF($D2="", "", JOIN(",", FILTER($B:$B, $A:$A=$D2))) and then copy it down.
try:
=ARRAYFORMULA(SUBSTITUTE(REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(QUERY(QUERY(
IF(B2:B<>"", {A2:A&"×", B2:B&","}, ),
"select max(Col2) where Col2 !='' group by Col2 pivot Col1")
,,999^99)), "×")), ",$", ), ", ", ","))
I have a Google Sheets column where the only possible values should be combinations of values from another column. So in this image, the cell with product 4 would be rejected since it is not from column C
Normally, I would just use the data validation feature, but combinations of values such as "product 1, product 2" would also not be allowed since they are not "product 1" or "product 2" exactly and data validation only allows exact values from other columns.
I tried using a custom formula with Regexmatch, but I haven't managed to work it out as to only allow values from the specified column and had to resort to hardcoding it in, as such
=regexmatch(A1,"product 1"|"product 2"|"product 3")
but when I add a new value to the data column, I have to modify the formula again so it is not an optimal solution.
How Do I go about doing this now because I haven't found much info online?
you can play this out like:
=ARRAYFORMULA(REGEXREPLACE(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(IFERROR(SPLIT(A2:A, ","))<>"",
IF(REGEXMATCH(IFERROR(SPLIT(A2:A, ",")), TEXTJOIN("|", 1, C2:C)),
REGEXEXTRACT(IFERROR(SPLIT(A2:A, ",")), TEXTJOIN("|", 1, C2:C))&",", "♦"), ))
,,999^99)), "where not Col1 contains '♦'", 0), ",$|, $", ))
I would like to create a scatterplot or bubble graph that will show one point for an employee's annual salary based on total years worked for the company and compare it to all of the other employees.
However, the employee logging in will only be able to see detailed information about their point. All other points need to be anomymized.
I have a control table of employees that is using RLS with a user role.
when the user logs in, They can only see their salary data from other tables joined to the employee control table.
I would like to add a table with all other employee's salary info without their Employee IDs, Names, ETC to display all in a scatter plot.
Thanks.
Building on what is shown in this post by Darren Gosbell1, here is a suggestion for you. My model involves three tables, one with the interesting information and two which are the employee dimension, vertically partitioned into public and private columns.
Salary & Experience =
DATATABLE(
"Employee ID", INTEGER, "Salary", CURRENCY, "Experience", INTEGER,
{
{1, 100000, 20},
{2, 80000, 5},
{3, 75000, 0},
{4, 120000, 6},
{5, 45000, 35}
}
)
Employees (Public) =
DATATABLE(
"Employee ID", INTEGER, "Sex", STRING,
{
{1, "F"},
{2, "M"},
{3, "F"},
{4, "M"},
{5, "F"}
}
)
Employees (Private) =
DATATABLE(
"Employee ID", INTEGER, "Name", STRING,
{
{1, "Me"},
{2, "Fred"},
{3, "Sally"},
{4, "Bob"},
{5, "Irene"}
}
)
We just then set up one-to-many relationships between 'Employees (Public)' -> 'Salary & Experience' and 'Employees (Public)' -> 'Employees (Private)' using the [Employee ID] column.
We can create some roles which filter the 'Employees (Private)' table based on the identity of the current user.
Then we make the scatter plot as you described, being careful to use a unique attribute from the public partition of the employees table as the details for the plot. Note that when viewing as employee "Me" I can see name of that employee, but not another employee.
I'm sure that your filter you define in the roles will me more interesting than mine.
1: Which describes a theoretical implementation of column-level security in SSAS tabular using vertical partitioning.
I have data in the PowerBI which I need to crosstab in order to generate the base data for a specific visual.
Example data:
tblExample = DATATABLE("Customer ID", INTEGER, "Gender", STRING, "Age Range", STRING, "Order Date", DATETIME, "WS Next Day", STRING, "Order Next Day", STRING, "WS Next Week", STRING, "Order Next Week", STRING, "WS Next Month", STRING, "Order Next Month", STRING,
{
{1, "Female", "30 - 39", "2017-02-09", "Yes", "No", "Yes", "No", "No", "No" },
{2, "Female", "30 - 39", "2017-02-11", "Yes", "Yes", "Yes", "No", "No", "No" },
{3, "Female", "50 - 59", "2017-02-12", "Yes", "No", "Yes", "No", "No", "No" },
{4, "Male", "20 - 29", "2017-02-12", "Yes", "No", "Yes", "No", "No", "No" },
{5, "Male", "40 - 49", "2017-02-19", "No", "No", "Yes", "No", "No", "No" }
}
)
This data shows customers who have placed an order and then a set of six yes / no flags showing whether or not the customer has visited the web site again the following day / week / month, and whether this visit resulted in another order.
What I need to do is turn this information into a table with one row for each category of "Next Day", "Next Week" and "Next Month", and for each row a value showing the count of customers who (a) visited and (b) purchased.
I thought this would be pretty straight forward to do in DAX - and to be honest I'm not sure that it isn't and I haven't just missed something really obvious - but at the moment I can't see a tidy way to achieve this.
I have created measures for each of the six values I need as follows:
NextDay_Visits = COUNTROWS(FILTER(tblExample, [WS Next Day] = "Yes"))
NextDay_Orders = COUNTROWS(FILTER(tblExample, [Order Next Day] = "Yes"))
And so on, and when I look at these measures in a card they give me the correct values, but to jam these into a table which is the correct shape I do the following (which is almost certainly the wrong way to do this in PowerBI !):
1 Create a new table
tblJunk1 = DATATABLE("Row ID", INTEGER, "Category", STRING, { {1, "Next Day"} })
2 Add the appropriate measures to the new table as new columns
tblJunk2 = ADDCOLUMNS(tblJunk1, "Visits", [NextDay_Visits], "Purchases", [NextDay_Purchases])
3 Do the same two steps again using tblJunk3 / tblJunk4 for the "Next Week" figures
4 Do the same two steps again using tblJunk5 / tblJunk6 for the "Next Month" figures.
5 Create a final table to use as the basis for my column chart by union-ing tblJunk2 / tblJunk4 / tblJunk6
tblChartBase = UNION(tblJunk2, tblJunk4, tblJunk6)
Then it's good news / bad news, because although this seems to me to be a horrible hack solution, I do get the table I need with the correct figures and the correct shape, and I can base a column chart on it which gives me the analysis I am looking for. (Good News!)
However, once I add slicers to the page based on "Gender" and "Age Group", the measures in this new table do not respond to them and the figures do not change meaning that this is not the way to achieve what I want. (Bad News)
I am not sure whether I am kind of hedging around the correct methodology but need to tweak my DAX for the measures so they do respond to the slicers on the page, or whether this is totally the wrong approach from the ground up?
Any suggestions / pointers gratefully received.
I would address this requirement in the Query Editor. It has Unpivot functionality that should meet your needs, e.g.
https://support.office.com/en-us/article/unpivot-columns-power-query-0f7bad4b-9ea1-49c1-9d95-f588221c7098
The Query Editor has added a few more options since that article was written, like Unpivot Other Columns, Unpivot Only Selected Columns.