How to have Running Count Items Within a Start and End Date in Amazon Quicksight - amazon-web-services

I have data like this brought into a SPICE from Redshift:
BadgeAward StartDate EndDate
Bronze 1/15/2017 1/15/2020
Silver 2/15/2019 2/15/2020
Gold 3/15/2017 3/15/2020
Gold 3/15/2017 3/15/2020
I am putting a line graph to show at a point in time (StartDate), how many are active
At 1/15/2017, Total Badges = 1 (Only Bronze is active)
At 2/15/2019, Total Badges = 4 (Gold,Bronze and Silver are still active)
At 3/15/2017, Total Badges = 3 (Gold and Bronze are active, Silver has not started yet)
I have been playing around with RunningCount but cannot seem to get it right.

I recreated your data set and what I thought would work with a runningcount formula. As you pointed out, it doesn't seem to work. QuickSight appears to be applying a distinct_Count logic as a part of the runningcount formula instead of a pure count.
To get around the issue I create a separate calculated field in which I assigned a value of 1 to assign a 1 to every row in the data. Then I did a runningsum formula based off that field to get your desired output.
BadgeCount = runningsum(sum(1),[STartDate ASC],[])

Related

How to split graphs in two halves (15 days each)

I want to split graph in two halves of 15 day each using dates
i have tried using Top N filters Top and Bottom but when date range is changed i have duplicated graphs.
Split is happening using above filter but when i reduce date filter range duplicate data is shown in two graphs
i tried Flag = IF(DAY(MAX('Table'[Date]))<=15,1,2) as well but was getting data not in sequential order
I'm new to this any help will be thankful.
I just split it in half, rather than by 15 days. But you could change the math to use 15 days instead, if that's what you still want. Regardless, seeing this might help.
I started with a table like this, called Sheet1:
Then I created a chart like your original:
Then I created this DAX measure:
Chart Selector =
var minDate = CALCULATE(FIRSTDATE(Sheet1[Date]), ALL(Sheet1[Date]))
var maxDate = CALCULATE(LASTDATE(Sheet1[Date]), ALL(Sheet1[Date]))
var midDate = minDate + (DATEDIFF(minDate, maxDate, DAY)/2)
return
IF(CALCULATE(SUM(Sheet1[Date]),FILTER(Sheet1,Sheet1[Date]<=midDate)),"First","Second")
(You could change the midDate variable's calculation, above, to one that does 15 days instead.)
Then I made two copies of the chart and, in each copy, I added the new measure to the chart's filters. In the first chart's filter, I filtered for if it contains "First." For the second chart's filter, I filtered for if it contains "Second."
My end result looks like this:

Tableau: percentage of total for specific dimension / COUNTD IF statement

I have an employee dataset and I'm trying to display the proportion of BAME staff only as a KPI. My dataset has duplicate lines (staff who have more than 1 role) and so I have to use a distinct count of their staff IDs (i.e. cannot use measure values or SUM) as I want to measure ethnicity per person not per role. The only way I can get the % of BAME across the population is by having all other categories visible however I am looking for a way to display the % of BAME across total only. For example in a table calc BAME = 12%, Non-BAME=85% and Unknown=3% - I want to keep the 12% only to put on my dashboard.
I've not needed to do this in Tableau before and I'm quite new to the software. Is there a way to do this? I thought that perhaps I would need to do an IF statement similar to Excel but the below syntax returns an error.
IF [Ethnic Group]="BAME" THEN COUNTD([Staff ID]) / COUNTD([Staff ID]) END
Thank you so much in advance!
COUNTD(IF [Ethnic Group]="BAME" THEN [Staff ID] END)/COUNTD([Staff ID])

Create a measure which divide two KPIs based on different periods

I have a table as presented below.
I would like to calculate KPI (#Handled/#Total Offered) and present it using CREATION YEAR MONTH NUMBER on chart but when I am trying to calculate it, it changes to 100% as #handled = #total offered.
#Total Offered = DISTINCTCOUNT(TABLE[REFERENCE_NUMBER])
#Handled = CALCULATE(DISTINCTCOUNT(TABLE1[REFERENCE_NUMBER];TABLE1[IS_CASE_CLOSED])=1))
#Total Offered is presented by CREATION_YEAR_MONTH_NUMBER
#Handled is presented by CURRENT_CASE_STAGE_YEAR_MONTH_NUMBER
I would like to do it as presented below:
Do you have any idea how to solve the case?
Can you try this below 2 Measure? If your coulmn is_case_handled contain always 0 and 1 properly, these simple below measures should work for you.
total_offered = count(your_table_name[is_case_closed])
total_handled = sum((your_table_name[is_case_closed]))

I'm trying to get Last month to date in Power BI

I have a Power Bi dashboard tracking several metrics since the beginning of last month . Some of the comparisons I make are MTD vs Last MTD count of metrics like Total users, No of posts and connections made.
MTD(June) and LMTD(May) were working well last month(June) but when we moved to a new month(july) the numbers are off.
Here's my measure
MTD_Users = CALCULATE(COUNTROWS('reporting profiles'), FILTER('reporting profile', MONTH('reporting profile'[date_created])=MONTH(TODAY())))
LMTD_USERS = CALCULATE(COUNTROWS('reporting profiles'), FILTER('reporting profile', MONTH('reporting profile'[date_created])=MONTH(TODAY())-1))
Since July 2nd these measures are not displaying correct figures for MTD(July 1st) and LMTD(June 1st)
Any advice/assistance will be highly appreciated
You need to ride off contex filter and that mean we must use function ALL or REMOVEFILTERS;
https://dax.guide/removefilters/
https://dax.guide/all/
LMTD_USERS = CALCULATE(COUNTROWS('reporting profiles'), FILTER(ALL('reporting profile'[date_created])), MONTH('reporting profile'[date_created])=MONTH(TODAY())-1))

Power BI Dashboard where the core filter condition is a disjunction on numeric fields

We are trying to implement a dashboard that displays various tables, metrics and a map where the dataset is a list of customers. The primary filter condition is the disjunction of two numeric fields. We want to the user to be able to select a threshold for [field 1] and a separate threshold for [field 2] and then impose the condition [field 1] >= <threshold> OR [field 2] >= <threshold>.
After that, we want to also allow various other interactive slicers so the user can restrict the data further, e.g. by country or account manager.
Power BI naturally imposes AND between all filters and doesn't have a neat way to specify OR. Can you suggest a way to define a calculation using the two numeric fields that is then applied as a filter within the same interactive dashboard screen? Alternatively, is there a way to first prompt the user for the two threshold values before the dashboard is displayed -- so when they click Submit on that parameter-setting screen they are then taken to the main dashboard screen with the disjunction already applied?
Added in response to a comment:
The data can be quite simple: no complexity there. The complexity is in getting the user interface to enable a disjunction.
Suppose the data was a list of customers with customer id, country, gender, total value of transactions in the last 12 months, and number of purchases in last 12 months. I want the end-user (with no technical skills) to specify a minimum threshold for total value (e.g. $1,000) and number of purchases (e.g. 10) and then restrict the data set to those where total value of transactions in the last 12 months > $1,000 OR number of purchases in last 12 months > 10.
After doing that, I want to allow the user to see the data set on a dashboard (e.g. with a table and a graph) and from there select other filters (e.g. gender=male, country=Australia).
The key here is to create separate parameter tables and combine conditions using a measure.
Suppose we have the following Sales table:
Customer Value Number
-----------------------
A 568 2
B 2451 12
C 1352 9
D 876 6
E 993 11
F 2208 20
G 1612 4
Then we'll create two new tables to use as parameters. You could do a calculated table like
Number = VALUES(Sales[Number])
Or something more complex like
Value = GENERATESERIES(0, ROUNDUP(MAX(Sales[Value]),-2), ROUNDUP(MAX(Sales[Value]),-2)/10)
Or define the table manually using Enter Data or some other way.
In any case, once you have these tables, name their columns what you want (I used MinNumber and MinValue) and write your filtering measure
Filter = IF(MAX(Sales[Number]) > MIN(Number[MinCount]) ||
MAX(Sales[Value]) > MIN('Value'[MinValue]),
1, 0)
Then put your Filter measure as a visual level filter where Filter is not 0 and use MinCount and MinValues column as slicers.
If you select 10 for MinCount and 1000 for MinValue then your table should look like this:
Notice that E and G only exceed one of the thresholds and tha A and D are excluded.
To my knowledge, there is no such built-in slicer feature in Power BI at the time being. There is however a suggestion in the Power BI forum that requests a functionality like this. If you'd be willing to use the Power Query Editor, it's easy to obtain the values you're looking for, but only for hard-coded values for your limits or thresh-holds.
Let me show you how for a synthetic dataset that should fit the structure of your description:
Dataset:
CustomerID,Country,Gender,TransactionValue12,NPurchases12
51,USA,M,3516,1
58,USA,M,3308,12
57,USA,M,7360,19
54,USA,M,2052,6
51,USA,M,4889,5
57,USA,M,4746,6
50,USA,M,3803,3
58,USA,M,4113,24
57,USA,M,7421,17
58,USA,M,1774,24
50,USA,F,8984,5
52,USA,F,1436,22
52,USA,F,2137,9
58,USA,F,9933,25
50,Canada,F,7050,16
56,Canada,F,7202,5
54,Canada,F,2096,19
59,Canada,F,4639,9
58,Canada,F,5724,25
56,Canada,F,4885,5
57,Canada,F,6212,4
54,Canada,F,5016,16
55,Canada,F,7340,21
60,Canada,F,7883,6
55,Canada,M,5884,12
60,UK,M,2328,12
52,UK,M,7826,1
58,UK,M,2542,11
56,UK,M,9304,3
54,UK,M,3685,16
58,UK,M,6440,16
50,UK,M,2469,13
57,UK,M,7827,6
Desktop table:
Here you see an Input table and a subset table using two Slicers. If the forum suggestion gets implemented, it should hopefully be easy to change a subset like below to an "OR" scenario:
Transaction Value > 1000 OR Number or purchases > 10 using Power Query:
If you use Edit Queries > Advanced filter you can set it up like this:
The last step under Applied Steps will then contain this formula:
= Table.SelectRows(#"Changed Type2", each [NPurchases12] > 10 or [TransactionValue12] > 1000
Now your original Input table will look like this:
Now, if only we were able to replace the hardcoded 10 and 1000 with a dynamic value, for example from a slicer, we would be fine! But no...
I know this is not what you were looking for, but it was the best 'negative answer' I could find. I guess I'm hoping for a better solution just as much as you are!