Iron Python Script for Last 4 Quarters or Last 4 Years based on property control in spotfire

24 views Asked by At

I have a bar chart with Last 4 Quarter results. When I Select 2023 Q4 ( IT IS SHOWING 2023 Q1 Q2 Q3 Q4) Results When I select 2023 ALL - It is only showing 2022 Q4 it has to show 2022,2023 Year records.

Ironpython script: Iron Python Script:

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import *

myVis = myVis.AsVisualization

if Document.Properties["PQuarter"] == 'All':

myVis.XAxis.Expression = "<[Impact_year]>"

myVis.Data.WhereClauseExpression = ''

myVis.Data.WhereClauseExpression = "([Impact_year]>=String(Integer('${PYear}')-3) and [Impact_year]<String(Integer('${PYear}')+1))"

else :

myVis.XAxis.Expression = <PruneHierarchy([VW_PUBS01_SAMPLES_QR].[Hierarchy.Year_Quarter_New],1)>

myVis.Data.WhereClauseExpression = ''

myVis.Data.WhereClauseExpression ="(Case When '${PQuarter}'='Q4' then ([Impact_year]=('${PYear}') and [Quarter_Hierarchy]<= ('${PQuarter}')) else (Integer([Impact_year])=(Integer('${PYear}')-1) and [Quarter_Hierarchy]> ('${PQuarter}')) or (([Impact_year])=('${PYear}') and [Quarter_Hierarchy]<= ('${PQuarter}')) end)"

Both If and Else conditions are satisfying.

When ever I change value in "Pquarter" it is working once.

Suppose if i select Pquarter = 'All' it should show Year summary results if i select Pquarter = 'Q4' it should show last 4 quarters results (q4,q3,q2,q1) if i select Pyear = '2023' and Pquarter = 'Q2' it should show last 4 quarters results (q2,q1,2022 q4,2022 q3))

0

There are 0 answers