Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Maddineni_S
Contributor III
Contributor III

Default sum should show current latest month

Hello members,

Can someone guide me to write an expression which shows default KPI value will be for latest month. and from filter when i select another month it should show for the respective selected month. 

Labels (2)
6 Replies
sidhiq91
Specialist II
Specialist II

May be try something like below:

if(isnull(GetCurrentSelections()),Date(Today(),'MMM YYYY'),[Field Name])

 

sidhiq91
Specialist II
Specialist II

May be you can try below as well. Let me know if it working fine as per your requirement.

=if(isnull(GetCurrentSelections()),Date(AddMonths(Today(),0),'MMM'),GetFieldSelections(Month))

Maddineni_S
Contributor III
Contributor III
Author

Lets assume that in a KPI, i want to show sum of sales by default for latest month and if select specific month from filter it should show the sales for that specific month.

abhijitnalekar
Specialist II
Specialist II

what would be the result required if more than months get selected.

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
sidhiq91
Specialist II
Specialist II

Maddineni,  Assuming 'Month' is the field name for Month, 'LinesalesAmount' is field name for Sales, OrderDate is the name of the Date field. Then you can use the below Expression. Please close this as a solution if it solves  your issue. 

if(isnull(GetCurrentSelections()),Sum({<Month={"$(=Month(Max(OrderDate)))"}>}LineSalesAmount),
sum({<Month={'$(=GetFieldSelections(Month))'}>}LineSalesAmount))

 

sidhiq91
Specialist II
Specialist II

If you want to select multiple Months at once, you can use below expression.

if(isnull(GetCurrentSelections()),Sum({<Month={"$(=Month(Max(OrderDate)))"}>}LineSalesAmount),
sum({<Month={$(=concat(DISTINCT chr(39) & Month & chr(39),','))}>}LineSalesAmount))