I have 1 spreadsheet with two columns: sku and old_url, and another with sku and new_url.
I want to make a new sheet with sku, old_url and new_url.
Some of the SKUs aren't in both, these should be discarded.
Is this possible?
Well this could be done using ISBLANK(), OR(), and IF() functions:
=IF(OR(ISBLANK(C11),ISBLANK(E11)),0,J11)
Suppose sku_with_old is at C (and olds are at D), and sku_with_new is at E (and news are at F). This expression then is a way to get skus which are only in both... Similarly you can get olds and news in H and K columns.
Let me know if You'd like to make it this way - but can't.
Related
I have a data visualization in PowerBI that is powered by SQL on the back-end. I have one particular field that I'd like to be able to filter by string-matching. Here's what the field looks like:
me_drug_occurence
AB
C
ABC
BC
B
Each letter is unique and stands for a type of drug. More letters = combinations of drugs. No letter repeats more than once for a record. I want to use the "Filters on the page" option and have the user be able to filter by drug A, B, and C. By selecting A, for example, that would show any record that contains A (records AB, ABC,). Selecting A and B would show any record which contains A OR B (records AB, ABC, BC, B). And so on and so forth.
My issue is that there doesn't seem to be an out-of-the-box way to do this in Power BI? If I simply drag this column to the "filters on this page" sidebar, I just get options to filter by the different drug combinations.
If I choose "advanced filter", I can get closer to my goal, but it forces the user to put the keywords in manually:
So, my question is how can I accomplish a filter on this visualization that would look something like this:
Filter:
A
B
C
Where you could filter by any record that contained A, B, or C, or some combination thereof. Do I need to create a custom measure?
You already are on right path.
Use Advanced filtering.
In this use OR condition
I.e
drug contains C or drug contains B or drug contains A
This will filter out your records with only those which have either of above 3 condition matched.
Edit:
This is closest I could come up with your req.
1 Use slicer, for this slicer add filed drug occurence make it dropdown and searchable.
Now as a end user I will type in A so i get N no of records which will contain A.
As I user I will select all those records as screenshot below
and then If I type C it will show as below and select them as well
This will be the result
Now there is one filter on market place called Text Filter. Import it from marketpalce and there you can search like text (contains) but there you cannot add three different conditions. It will look something like below
Without text filter
After adding text for filter
I'm trying to use slicer values as calculated column or something that works like one
I've seen this post
https://community.powerbi.com/t5/Desktop/Slicer-Value-in-Column-Formula/m-p/214892#M95071
but not sure how to proceed with the following case
I have registers from a sort of SCD with ValidStartDate and ValidEndDate
User should be able to set 2 slicers: AnalysisStartDate and AnalysisEndDate
I should be able to count registers based on those two dates, for instance
how many registers have ValidStartDate between AnalysisStartDate and AnalysisEndDate?
how many registers have ValidEndDate between AnalysisStartDate and AnalysisEndDate ?
Anyhelp appreciated
Looks like I managed to get to what i wanted
First you need a "measure" version of the columns you want to use in calculation just using FIRSTDATE() for instance -- I think it's very important to create the measure in the same table
To capture slicer value in a measure using something like:
if it has one value, get the value, otherwise use first value (or whatever you want)
x Analisis Inicio = IF(HASONEVALUE(TD_FECHAS_INICIO[DT_ANALISIS_INICIO]);VALUES(TD_FECHAS_INICIO[DT_ANALISIS_INICIO]);FIRSTDATE(TD_FECHAS_INICIO[DT_ANALISIS_INICIO].[Date]))
Now you can start creating measures which compare both
x SW_ES_ALTA =
IF(
AND([x Inicio Measure] >= [x Analisis Inicio]
; [x Inicio Measure] <= [x Analisis Fin])
;"SI"
;"NO"
)
and even counts of this last measure
x HC_ES_ALTA = COUNTAX(FILTER(ZZ_FLAGS_INMUEBLE;[x SW_ES_ALTA]="SI");ZZ_FLAGS_INMUEBLE[ID_INMUEBLE])
Not the easiest path, and probably you can put several of these measures in a single one, but if it works, it works...
I have some table data in which I'd like to sum all the values in a specific column of all rows where column A contains string A and/or column B contains string B. How can I achieve this?
This works for one criterium:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")))
I tried this, but it didn't work:
=SUM(FILTER(G:G,OR(ISTEXT(REGEXMATCH(F:F,"stringA")),ISTEXT(REGEXMATCH(C:C,"stringB")))))
Please try:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")+REGEXMATCH(C:C,"stringB")))
+ works for or logic. ISTEXT is not needed because REGEXMATCH gives true or false.
OR does not work because filter is an arrayformula, use + in array formulas.
=SUM(FILTER(G:G,REGEXMATCH(F:F&C:C,"stringA|stringB")))
OR is denoted by |
EDIT Added &C:C to denote different Columns
I have a table with columns, a, b, c, d, e.
Each column is given a random numerical value.
I can then order by that numerical value.
query_results = UserProfile.objects.all().order_by('a')
What i want is the ability to order by the sum of 2 or 3 or even 5 columns. But i cant figure out how to do it lightly.
My answer so far has been some what convoluted. I add an extra column x.
cursor.execute("UPDATE mysite_userprofile SET x = a+b;")
I then order by x. I have to update the column x each time i want different columns added together.
This is not the way to do it i know. i know order_by('a+b') doesn't work but is their another solution just as simple. I looked on django's site but couldn't find anything
The best way is to use extra
UserProfile.objects.extra(
select={'sum_of_fields': 'a + b + c + d + e'},
order_by=('sum_of_fields',)
)
I think you can order the result in the SQL query. Before you run the SQL query, when you select the columns, you can build the query string in the background.
I am returning a SQL dataset in SSRS (Microsoft SQL Server Reporting Services) with a one to many relationship like this:
ID REV Event
6117 B FTG-06a
6117 B FTG-06a PMT
6117 B GTI-04b
6124 A GBI-40
6124 A GTI-04b
6124 A GTD-04c
6136 M GBI-40
6141 C GBI-40
I would like to display it as a comma-delimited field in the last column [Event] like so:
ID REV Event
6117 B FTG-06a,FTG-06a PMT,GTI-04b
6124 A GBI-40, GTI-04b, GTD-04c
6136 M GBI-40
6141 C GBI-40
Is there a way to do this on the SSRS side of things?
You want to concat on the SQL side not on the SSRS side, that way you can combine these results in a stored procedure say, and then send it to the reporting layer.
Remember databases are there to work with the data. The report should just be used for the presentation layer, so there is no need to tire yourself with trying to get a function to parse this data out.
Best thing to do is do this at the sproc level and push the data from the sproc to the report.
Based on your edit this is how you would do it:
To concat fields take a look at COALESCE.
You will then get a string concat of all the values you have listed.
Here's an example:
use Northwind
declare #CategoryList varchar(1000)
select #CategoryList = coalesce(#CategoryList + ‘, ‘, ”) + CategoryName from Categories
select ‘Results = ‘ + #CategoryList
Now because you have an additional field namely the ID value, you cannot just add on values to the query, you will need to use a CURSOR with this otherwise you will get a notorious error about including additional fields to a calculated query.
Take a look here for more help, make sure you look at the comment at the bottom specifically posted by an 'Alberto' he has a similiar issue as you do and you should be able to figure it out using his comment.