Semi Circle in Tableau Start at 270 and not 0 - tableau-api

I have many calculated fields that come up with a percentage based on the number of days payment was made. I am using those calculated fields in place of the parameter [Percentage]. There is no number identifier to associate as instructed on the following website. I have the calculations done, the case statement and the color field. There is no Number Identifier, so I have no [SLICE#]
https://www.flerlagetwins.com/2018/01/percentage-gauges-in-tableau_61.html
I have a 96.02% and it always starts at 0 or 12 o'clock. I need it to start at 270. SAnd "Hidden" or "None" does not work in the Color Field.

I ended up duplicating my calculations and for each, I did for [Payment % 1 of 2]
IF([Payments] / [Total Default]) > .5 Then
( Payments] / [Total Default]) - .5
ELSE [Payments] / [Total Default] END
and for [Payment % 2 of 2]
IF( Payments] / [Total Default]) > .5 Then
([Payments] / [Total Default]-[Payment % 1 0f 2])
ELSE [Payment % 1 0f 2] END
And then just reorder them and make them the same color.
While having a calculation of 1 at the bottom

Related

Dynamic color format values - Tableau

I want to color format the values (.csv file format) based on the below conditions in tableau desktop.
If consecutive increase of the values or same values with increase values from start Date then values should be Red color .
If Consecutive decrease of the values from startDate then values color should be Green Color
If the values are Increase and then decrease from start date then Yellow.
If the values are decrease then increase then yellow.
For the above data the expected color for the student values should be below..
Student:Mon,Pat,Henry,Kim Yellow,
Jack,stanley Red
Kevin,Lendl -Green
I have tried below code but not working as expected..
Please correct if i missing any thing thing.
//Green - consecutive downward trend
if
window_sum(if FIRST() = 0 then 0
elseif sum([Value]) < lookup(sum([Value]),-1) then 1
end) = MAX([Number of Days]) then "Green"
//Yellow - downward and upward trend but not consecutive
elseif window_sum(if FIRST() = 0 then 0
elseif sum([Value]) < lookup(sum([Value]),-1) then 1
end) > 0 and
window_sum(if FIRST() = 0 then 0
elseif sum([Value]) < lookup(sum([Value]),-1) then 1
end) < MAX([Number of Days]) then "Yellow"
//Red - consecutive upward trend
elseif
window_sum(if FIRST() = 0 then 0
elseif sum([Value]) > lookup(sum([Value]),-1) then 1
end) = MAX([Number of Days]) then "Red"
end
Thanks for your help in advance !!
Without knowing your data structure you can look into table calculations. This may not be straightforward, especially to get the "Compute Using" settings right, but some logic as follows may work.
Calculate the day on day differences (a table calculation will do that).
If the day on day diff is positive then give it a value 1, is negative set it to -1. This would be an IF statement around your table calculation.
Next SUM the result.
Calculate how many dates there are, which will provide the maximum possible number if all are increasing or decreasing every day.
Finally compare the result of the summing if up or down with the maximum possible. This field can sit on the colour shelf.
I haven't tested any of this but, from a logic perspective, you may be able to make this work.
Edit based on comments:
Build the following calculated fields, it should work. You'll be able to troubleshoot calc by calc if having "compute using" challenges. Put the [Colour] field on the colour shelf:
[DailyDiff]: ZN(SUM([Value])) - LOOKUP(ZN(SUM([Value])), -1)
[isUpOrDown]: IF [DailyDiff] >0 THEN 1 ELSEIF [DailyDiff] <0 THEN -1 ELSE 0 END
[TotalUpOrDown]: WINDOW_SUM([isUpOrDown])
[NumDays]: {COUNTD([Date])}-1 //1 less to account for the first day
[Colour]: IF [TotalUpOrDown] = MIN([NumDays]) THEN "Increasing" ELSEIF [TotalUpOrDown]=-MIN([NumDays]) THEN "Decreasing" ELSE "Other" END

Conditional formatting in Tableau connected to Cube data

Could someone help me to color these measures on 3 variations - less than 0, equal to 0 and greater than 0. I tried with a calculation
IF [Margin 1] > 0 THEN 1 ELSEIF [Margin 1] < 0 THEN 2 ELSEIF [Margin 1] = 0 THEN 3 END
The reason I have assigned numbers instead of string in the above calculation is, the data is from a cube which will not allow string to be mixed with IF conditon
This is only for Margin 1 while a similar one is also required for Margin 2 and Margin 3 as well. Once I put this calculation to color shelf it colored first value of Margin 1 correctly but at the same time even colors Margin 2 and Margin 3 as well with same shade.
Could someone help to nest color logic calculation for all three Margins so I can have control to choose less than, equal to and greater than 0 in different shades.
Attached is the image of data and tableau sheet of what I have arrived as of now, do let me know for any other details
Not sure how the fact the data is from cube makes much difference, inside of tableau you're looking at a integer and returning a string shouldn't matter.
If you want give this a try
create a calculated field like this:
ZN([Margin 1]) + ZN([Margin 2]) + ZN([Margin 3])
Then create your if statement based on the new calculated field returning string
If [NewCalculated field] <0 then
"Red"
If [NewCalculated field] 0 then
"Amber"
Else
"Green"
End
Have a go

Tableau Formatting Numbers in calculated field

I have a calculate field named Table Measure, and it contains Percent and Numbers. How can I format the % with 1 decimal place and the number of records with comma and zero decimal place? I tried to use FORMAT([% of Composite VOC]),"#.0%") it gave me an error.
IF [Toggle] = 1 THEN ([% of Sale 1]) ELSEIF [Toggle] = 2 THEN [Total of
Profit] ELSEIF [Toggle] = 3 THEN [% of Discount] ELSEIF [Toggle] = 4 THEN % of
Commission ] ELSEIF [Toggle] = 5 THEN [Number of Records] END) END
Right click on the calculation "Table Measure" -> Select "Default Properties" -> "Number Format" -> "Percentage"...update to 1 decimal.

How to create a percent on a column graph chart?

I have a column graph chart in SSRS 2008 R2 and now I want to display the values as a percent. Currently it just displays the sum totals. My dataset looks like:
people_count facility met_reqs
12 Chattanooga, TN 0
9 Clarksville, TN 0
6 Columbia, TN 0
51 Chattanooga, TN 1
22 Clarksville, TN 1
28 Columbia, TN 1
As you can see, each city has two rows: the first row is the count of persons who did not meet requirements and the second row is for each city which did meet reqs.
Where my last query is:
select
count(distinct people_id) as people_count,
facility,
case when total_los/total_visits *3/7 >= 1 then 1 else 0 end met_reqs
from #final
group by facility, case when total_los/total_visits *3/7 >= 1 then 1 else 0 end
Currently I have this chart to display the sum of people_count for Chart Values, Category Group = facility, and Series Group = met_reqs.
This looks like:
But now for the Y-axis I want this to instead display percentage of persons/facility who met the requirements. How can I do this? So the Y-axis should instead have a range of 0-100%.
Have you considered a 100 % Stacked Column chart?
If you change your existing setup this seems to achieve your requirements:
If this isn't what you're after, can you please update your questions with some more details?
Edit after comment
OK, to meet the specific requirement of displaying % Meeting Requirements only. With the same Dataset, use a Chart type of Column (i.e. the first option) and remove the Series Group:
Change the Values expression to:
=Sum(IIf(Fields!met_reqs.Value = 1, Fields!people_count.Value, Nothing))
/ Sum(Fields!people_count.Value)
i.e. getting the % of total people_count where met_reqs = 1 compared to the total people_count in each group.
For the sake of completeness I changed the number formatting on the Y axis to be percentage.
This looks OK to me:
Hopefully this help get a bit closer to the goal.

Start matlab for loop from non zero value

I have the code below in which I am trying to start the "number_panels" and "number_turbines" for loop from a non zero number.
More specifically I am trying for 3000 to 4000 "number_panels" with 500 panel interval
and from 5 to 8 "number_turbines" with one turbine interval
i.e
number_of_days = 2;
for number_panels = 3000:500:4000 % range of PV panel units examined
for number_turbines = 5:8 % range of wind turbine units examined
for h=1:24 %# hours
for d = 1:number_of_days %# which day
n = h + 24*(d-1);
% hourly_deficit_1(...,..., h, d)= Demand(n)-(PV_supply(n)... %
hourly_deficit(number_panels + 1, number_turbines + 1, h,d) = hourly_annual_demand(n) - (hourly_annual_PV(n)*number_panels) - (hourly_annual_WT(n)*number_turbines);% hourly power deficit (RES supply with demand)
if hourly_deficit(number_panels + 1, number_turbines + 1, h,d)< 0 % zero out negative hourly deficit values (this is power surplus from RES)
hourly_deficit(number_panels + 1, number_turbines + 1, h,d) = 0;
end
When I do this I get a size(hourly_deficit) = 4001,9,24,2 whereas I am expecting and trying to achieve a 3,4,24,2 size. Does anyone know where I am going wrong?
The value of the variable number_panels starts at 3000 instead of 0 or 1. Thus when you index a matrix with that variable as the index value Matlab thinks you are wanting the 3001st index and thus gives you a matrix that is 3000 zeros with the 3001st being set to what you ask.
If you follow the loop into it's next cycle the value of number_panels becomes 3500. You now are indexing at 3501, based on your code. This means that all of the places from 3002 to 3500 will be filled with zeros and 3501 will be set to whatever value you give it.
The same logic applies to number_turbines The only difference is that you'll be indexing by 1 instead of by 500 like you are with number_panels.
If you want to get back to the size matrix you are expecting you'll need to modify the way you call the index values. This could be done a number of ways. You could have a counter within the for-loop or you could use modulus math. Modulus math doesn't work well when you're using a step size that isn't 1. It also doesn't work when you get to the point where you have an index value that is a multiple of your starting index.
You'll have to work out what will work best for you in that arena. Especially since you want to use a step size that isn't 1. But for the number_turbines that goes from 5 to 8, you can simple index using number_turbines - 5 + 1 or more concise number_turbines-4.
For clarity, here is the code you provided with the necessary tweaks to show the use of what was mentioned in the comments. Please take note that you will need to modify the -4 for the number_turbines index value should you start at something other than 5. Also note that you need to index the number_panels vector now since it's not a looped value.
Hope this helps!
number_of_days = 2;
number_panels = 3000:500:4000;
for idx_number_panels = 1:length(number_panels) % range of PV panel units examined
for number_turbines = 5:8 % range of wind turbine units examined
for h=1:24 %# hours
for d = 1:number_of_days %# which day
n = h + 24*(d-1);
% hourly_deficit_1(...,..., h, d)= Demand(n)-(PV_supply(n)... %
hourly_deficit(idx_number_panels , number_turbines -4, h,d) = hourly_annual_demand(n) - (hourly_annual_PV(n)*number_panels(idx_number_panels)) - (hourly_annual_WT(n)*number_turbines);% hourly power deficit (RES supply with demand)
if hourly_deficit(idx_number_panels, number_turbines -4, h,d)< 0 % zero out negative hourly deficit values (this is power surplus from RES)
hourly_deficit(idx_number_panels, number_turbines -4, h,d) = 0;
end
end
end
end
end