How can I show cumulative percentage or sum of an attribute in a line chart power bi - date

I have a business requirement to show the trend of cumulative percentage of an atribute over last 2 years. I used a measure to create running total of the attribute for this year and the results are correct.However When I tried to apply the same logic for the past 2 years it is giving me incorrect values.I have created a date table that spans from 2021 to 2023 dec and The X axis of the chart displays weeknumber.Could some one help me with this issue?
Thanks in Advance!
The measure for this year :
Cumulative2023 =
CALCULATE(
DIVIDE(
'Table'[CY CountNum2023]
,'Table'[CY CountDen2023]
,0),
FILTER(
ALLSELECTED('Table'),
'Table'[CreatedDate] <= MAX('Table'[CreatedDate])
)
)

Related

Calculating monthly averages of daily temperature data including negative and positive values

I am trying to calculate monthly average temperatures for a dataset with daily temperature values that spans three years. With the data.frame appearing like this example"
Date Month Temperature
12-2-2016 December -10
12-3-2016 December -12
01-2-2017 January -15
01-3-2017 January -14
02-3-2017 February 3
02-4-2017 February 7
03-2-2017 March 8
03-3-2017 March 9
I tried running the following code in order to create a new dataframe with the Month and the average temperature:
group_by(df$month) %>%
summarise(mean_airtemp = mean(Temperature))
However, when running this code I get NA for certain months which I believe is attributed to negative values. I have tried to figure it out but have only found solutions that seem to separate the values based on whether they are negative or positive.
you can use groupby of month and temp together
df.groupby(['Month'])['Temperature'].mean().reset_index(name = 'avg')

Looking for YOY YTD formula that works with fiscal years in tableau

I am looking for YOY YTD formula that works with fiscal years in tableau.
Method 1 appears to work here: https://resources.useready.com/blog/ytd-cy-vs-py-in-tableau-2-methods/ but does not work for Fiscal years.
the current year filter starts at Jan.
Is there anyway to adjust method 1 to work with fiscal years?
Note: i tried default properties-> fiscal year start to July and that did not work
See "goal in tableau screenshot below"
You're almost there, assuming you computed what you're showing in Tableau
and didn't just mock it up in Excel.
If you don't have one, create a calculated field "FY-Number" where
January -> 1, Feb -> 2, etc. You're already sorting in that order
so maybe you already have such a field.
Assuming your "average" is a "total" ( using AVERAGE ),
all you need now is a filter to select FY-Number < 7.
Which you COULD do manually.
But if you want this to be automatic, and always total down to the most recent month, you could do the following. There may be better ways but this works.
And I have a hierarchy of FY-number and Fiscal-Month-number for generating the grid.
Compute a running number which we can maximize, a sequential number crossing all years, for the month. I used formula for FMRun to be
[FY num]*12 + [FM num]
which has a max of 270 for December 2021. Tableau can find the max.
Next, invert that, basically, to find the max month number.
FMInvert formula:
{FIXED :(MAX([FMRun])/12 - FLOOR(max([FMRun])/12))*12}
which has a value of 6 for the data given.
Finally, filter on that with this filter I called whatmax, which we want true:
if [FM num] <= [FMinvert] then TRUE
else FALSE
END
And voila, you're done.
Here's the workbook.
https://public.tableau.com/app/profile/wade.schuette/viz/YOY-YTD-answer/Dashboard1?publish=yes

How to calculate average for the calendar year

My input file consists of column Actual Exp and Actual Min.
Now I want to create a measure for calculating the average for the current calendar year having the latest month of data for Actual Exp and Actual Min.
I want to calculate the average from Jan'21 to Mar'21, and later if data gets added for Apr or May I would like to calculate the average from Jan'21 to May'21 or Apr'21.
Similarly, I want to have from Jan '21 to Dec'21 in Dec'21 and an average from Jan'22 to Feb'22 in Feb'22. I also have a date filter I don't want my date filter to affect the average.
I tried using TOTALYTD and MAX(Date), but it's not working.
Thanks.
I've not fully understood your question, but hopefully this helps:
AVERAGEX ( ALL(TABLENAME), TABLENAME[COLUMNNAME])
This should give you an average of COLUMNNAME no matter what filters/slicing you have in place.
If you wanted to futher restrict this, you can try creating a 2nd measure such as
CALCULATE(AVERAGEX ( ALL(TABLENAME), TABLENAME[COLUMNNAME]), datetable[monthcolumn] IN {"Jan", "Feb", "Mar"})

How do I show multiple lines on the same graph in tableau?

I have my graph set up, so that a sum total is in rows, and month is in columns. I would like to see the last three years as separately colored bars or lines in the same graph. I created sets for 2014,2015, and 2016, but for some reason can not get it to do what I have described above.
Thank you.
One way would be to create a calculated field that "groups" those 3 years into one value/label, then use that in the colors card.
The calculated field may look something like:
IF [YearField] >= 2014 AND [YearField] <= 2016 THEN 'Last 3 Years' ELSE STR([YearField]) END

How to Calculate YTD (Jan to prev month) in a single column in tableau

Original post - https://community.tableau.com/thread/206909
I have a report in which I have sales per month in the column and commodities in the row. The data show actual sales and future estimates for each month.
Need to calculate Year-To-Date (YTD) total for 2016 (from Jan to Previous month) and have it in a single column at the end of the actual values.
I already created a calculated field - YTD
IF
YEAR([DATE]) = YEAR(NOW())
AND
MONTH([DATE])< MONTH(NOW())
THEN
[VALUE/UNIT]
ELSE
0
END
But when I add to the view, it creates a another section for YTD with sum for each month till April.
Can someone please help me in how to achieve this in Tableau?
There are couple of ways to achieve this view in Tableau
1. To create calculated field for each Month and YTD and add measure names in Row & Measure values in Text
2. Make union of 2 queries - one that select all the correct values & second that have YTD calculation in month column. Then use pivot it