Find percetage in Crystal report - crystal-reports

Hi I'm new in crystal reporting, i would like to make percentage for annual year growth based current year with the previous year.
For example, I would like to check the growth for CMP4 for current year (2017) and previous year (2016).
CMP_vc_Code,InvYear,Jan,Feb,Mar,Apr,May,June,July,Aug,Sep,Oct,Nov,Dec
CMP1,2016,0,0,318.50,68.25,91,182,338,195.25,140.70,0,117.25,0
CMP2,2017,550.30,0,0,0,0,0,0,0,0,0,0,0
CMP3,2017,160.95,0,0,0,0,0,0,0,0,0,0,0
CMP4,2016,3226.90,13141,13131.40,5108.60,4148,5529.60,1082.25,12945.85,5002.30,2239.80,4035.40,4454.35
CMP4,2017,13362.85,8671.35,10233,0,0,0,0,0,0,0,0,0
I have details of the company sales (row data) which is given to the crystal report. So In crystal report, I first group by data based on year and company. Total of each month is generated dynamic using crystal report sum field. Please help me on this.

This should be close to what you are looking for...
1) Make sure your data is grouped be year. (Which it sounds like you are)
2) Insert a SUM summary in the year group footer. (Also sounds good just make sure its in the group footer)
3) Use a formula like this...
Global CurrencyVar b := IF GroupNumber = 1 THEN Sum ({TableName.DollarAmount}, {TableName.Year}) ELSE b;
Global CurrencyVar e := Sum ({TableName.DollarAmount}, {TableName.Year});
Local NumberVar p := IF b = e OR b = 0 THEN 0 ELSE ((e - b) / b * 100); // or whatever calculation you are using...
b := Sum ({TableName.DollarAmount}, {TableName.Year});
p
4) Place the formula field in the group footer, next to the SUM from step #2.

Related

DAX Calculate Billing Days Between Two Variable Dates

I have a dimdate table that is represented below. I have each day flagged as BusinessDay Y/N. I also have a DimSalesRep table that has a daily goal for each rep. I want to be able to allow users to input a StartDt and EndDt with filters on the report and have a calculated column look at the business days between those dates. I can calculate daysbetween with defined dates but I am unsure how I would use DAX with variable dates that are applied through Report filters.
I should also note I am not sure how best to handle a startdt and enddt filter based of the column, TheDate
Cheers!
Reference your dimdate table twice
StartDate = 'dimdate'
EndDate = 'dimdate'
and use this measure:
Num BusinessDays =
CALCULATE(
COUNTROWS('dimdate'),
'dimdate'[BusinessDay] = "Y",
'dimdate'[Date] >= SELECTEDVALUE(StartDate[Date]),
'dimdate'[Date] <= SELECTEDVALUE(EndDate[Date])
)

How to calculate total sales as of first day of the current month as Previous month sales in power BI

I have salesamount column and the saledate column in my table. so I need to calculate total sales for each month based on below calculation.
total sales for current month=sum(salesamount) as of 1st day of the next month
for example sales of December-2021 should be calculated based on the total sales as on Jan-1-2022. total sales for January should be blank until Feb-1-2022 as it should be the total sales as on feb-1-2022. I am very much confused how we can achieve this in Dax. Really appreciate your help.
If I understand your question correctly, you can use the following DAX measure:
Total Sales =
var currentDate = MAX(myTable[saleDate])
var firstOfMonth = DATE(YEAR(CALCULATE(MAX(myTable[saledate]), ALL(myTable))),
MONTH(CALCULATE(MAX(myTable[saledate]), ALL(myTable))), 1)
var result = SUM(myTable[salesamount])
Return IF(currentDate < firstOfMonth, result)
This will take the current date of the report context and compare it to the 1st of the current month. If the currentDate is less than the 1st of the current month, the result will be calculated.
If your dataset has a Date table, you can replace the 'myTable[saledate]' references with a reference to the Date column in your date table.
With some sample data, here are the results:
(I added the firstOfMonth column for demonstration purposes)

Unable to display view using two Parameters in Tableau

I have a "Select Year" Parameter for Year.
If I select from "Select Year", then I want to display results for Selected Year and Previous Year (both) in a CrossTab View on the same Sheet.
Please refer to attached to know more about my query.
*Other way (unwanted): *
I tried to create two Calculated Fields (Dimensions Filters for selecting the Year), then created two different sheets - "Selected Period Value" and "previous Period Value", but I want just one sheet to display it together.
//Selected Year
IF YEAR([Year]) = INT([Year Parameter]) THEN
INT([Year Parameter])
END
//Previous Year
IF YEAR([Year]) = INT([Year Parameter])-1 THEN
INT([Year Parameter])-1
END
Please assist.
Just assuming 46.34% and 46.85% as Profit measure.
Create two calculated fields, one for the year selected from parameter and the other for prior year.
Profit_Current calculated field:
IF YEAR([Year]) = INT([Year Parameter]) THEN Profit
ELSE 0 END
Profit_Previous calculated field:
IF YEAR([Year]) = INT([Year Parameter])-1 THEN Profit
ELSE 0 END
Use these two calculated fields in cross tab
Let us know if this works!

Yearly Report in Crystal Report

Hi I'm new in crystal reporting, i would like to make a yearly and monthly report when a button(Yearly Report) is click Yearly Report in crystal report is view. Should i make a formula? or just in Select Expert using is in the period as?Thank you in advance.
You should create a report parameter called: #ReportingPeriod
This can be a series of text options (Monthly, Weekly, Daily, etc.) or it can be numeric on the order of '# of months' (1, 3, 6, 12)
Then you need to edit the 'Report Selection Criteria...' as a formula and append the following code:
(
... EXISTING SELECTION CRITIERIA ...
)
AND
(
(#ReportingPeriod = "Yearly" && {CreateDate} < '1/1/2014')
OR
(#ReportingPeriod = "Monthly" && {CreateDate} < '1/1/2014' && {CreateDate} = '12/1/2014')
)
So the parameter you've created becomes the basis for the filter criteria enabling a variety of scenarios depending on the parameters value.
DISCLAIMER: This pseudo code is conceptual and is not valid Crystal Reports formula code.

Crystal Reports Date by Year Comparison on a Running Total

I am using Crystal Reports XI R2.
My table has transaction data by date. I have a group set up by day and a summary to give a count of transactions for each day. I also have a running total set to give a year to date count for each day. Of course it resets on a change in year.
My goal is to be able to find the difference between the YTD count yesterday and the same for the same date last year.
Edit: I've misstated the goal. It isn't to be able to find the difference for just yesterday, but for each day in a range of days.
Create these two formula fields:
//{#LastYearToDate}
If {table.dateField} IN LastYearYTD Then
1
Else
0
//{#ThisYearToDate}
If {table.dateField} IN YearToDate Then
1
Else
0
Insert a summary on each field in the ReportFooter section.
I finally got this nailed down. There is likely a cleaner way of doing this, but....
I converted the dates (started as text yyyy-mm-dd) into text mm/dd/yyyy format:
stringvar yyyyear := {table.dateField}[1 to 4];
stringvar mmonth := {table.dateField}[6 to 7];;
stringvar dday := {table.dateField}[9 to 10];
mmonth + "/" + dday + "/" + yyyyear
Grouped by this field and inserted a count summary into the group header. Created a separate field for the mm/dd portion of each date:
{#textDate}[1 to 5]
Added a flag to see if the date in the current group header matched the previous:
if previous({#mm/dd}) = {#mm/dd}
then 1
else 0
Used a shared variable to store the YTD totals for each year (2 formulas):
shared numbervar totalsCurentYear;
if {#prevDateFlag} = 1 then
totalsCurrentYear := totalsCurrentYear + Sum ({#transactionCount}, {#textDate});
totalsCurrentYear
|
shared numbervar totalsLastYear;
if {#prevDateFlag} = 1 then
totalsLastYear := totalsLastYear + Sum ({#transactionCount}, {#textDate});
totalsLastYear
Put both of these into the group footer (suppressed) and added a field to do the subtraction into the group header.