Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
twinklea
Partner - Contributor III
Partner - Contributor III

Previous Year Sales

Hi,

I need the calculation of total sales for the previous year irrespective of the MonthYear dimension in a table.

Below is the scenario:

MonthYearSalesPrevious Year Total Sales
Jan-183001000
Feb-187301000
Mar-184001000
Apr-184501000
Jan-171001460
Feb-172001460
Mar-173001460
Apr-174001460
Jan-163200
Feb-161800
Mar-164600
Apr-165000

Suppose for Jan2018 to Apr 2018 , it should calculate the sales from Jan 2017 to Apr 2017 and result as 1000 for all the 4 records and similar way for other years.

Please note that this output should also reflect filters from the dashboard.

Request the solution asap.

Regards,

Twinkle A

14 Replies
twinklea
Partner - Contributor III
Partner - Contributor III
Author

The sample is the same as previous one. I am getting 2000 for all the records of 2018 year now instead of 1000.
sunny_talwar

I meant a qvf file... because I am not sure what exactly you have beyond what I see here... if I recreate... I am almost certain, I won't see this problem...

twinklea
Partner - Contributor III
Partner - Contributor III
Author

I got the issue.. I had to remove the outer sum which is why it was getting doubled.

Now, your expression with Nodistinct function works fine for me.

Thank you so much.
sunny_talwar

good to know....

somacdc
Contributor III
Contributor III

 

I want to following result sir,

ELEMENT_IDACCOUNT_NUMBERCASH_DEPOSITTARIFF_DEDUCTEDSLABCASH_DEPOSIT_ADJUSTED(follow the below caculation)DIFF_TARRIF_ADJUST(TARIFF_DEDUCTED - CASH_DEPOSIT_ADJUSTED)CASH_BALANCE= (CASH_BALANCE-TARIFF_DEDUCTED)
9110293510000070(0-0)=0(1000-0)=1000
911029350412464124(4124-4124)=0(1000-4124)=5876
911029350412454124(4124-4124)=0(5876-4124)=1752
911029350412441752(4124-1752)=2372(1752-4124)=0
911029350412430(4124-0)=4124(0-4124)=0
911029350512420(5124-0)=5124(0-5124)=0
911029350512410(5124-0)=5124(0-5124)=0
92102937......7........
92102937......6........
92102937......5........
92102937......4........
92102937......3........
92102937......2........
92102937......1........
........................
.....      
So onSo onSo onSo on    

 

if(Cash_Balance>0) then
      if(Cash_Balance >= TARIFF_DEDUCTED) then
                 CASH_DEPOSIT_ADJUSTED := TARIFF_DEDUCTED;
      else
                CASH_DEPOSIT_ADJUSTED := TARIFF_DEDUCTED-abs(Cash_Balance-TARIFF_DEDUCTED);
      end if;
else
      CASH_DEPOSIT_ADJUSTED :=0;
end if;