Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Dax calculation

Hello guys I need these  calculation to work for a card visual to display the value of sum auditfile

CALCULATE(SUM('2 (Auditfile)'[saldo]), IF(VALUES('2 (Auditfile)'[fiscalYear])>2018,[fiscalyear]-1))
 
why doesnt it work i want the value of sum saldo  
many thanks :):):)

6 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      hey Shaurya  you got it almost i want sum of saldo when in a slicer is 2018 selected i want the sum saldo of 2017, when in the slicer 2019 is selected i want the sum of saldo from 2018, when 2020 is selected i want sum of saldo from 2019 etc etc       previeus year function doesnt work for me the way my data is but it think its something like your dax formula

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Here I suggest you to create an unrelated Fiscal Year Table for slicer and create a measure to achieve your goal.

        My Sample:

        Fiscal Year Table:

        Fiscal Year = VALUES(Auditfile[fiscalYear])

        Measure:

        Measure = 
        VAR _SELECTYEAR = VALUES('Fiscal Year'[fiscalYear])
        VAR _PREVIOUSYEAR = SUMMARIZE( ADDCOLUMNS(_SELECTYEAR,"PY",[fiscalYear] - 1),[PY])
        RETURN 
        CALCULATE(SUM(Auditfile[saldo]),FILTER(Auditfile,Auditfile[fiscalYear] IN _PREVIOUSYEAR))

        Result is as below.

         

        Best Regards,
        Rico Zhou

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    i need something like this :
    if(selectedvalue(auditfile[fiscalyear]=2019,selectvalue(auditfile[fiscalyear]-1),
    calculate(sum(auditfile[saldo])

    but this doesnt work, so i need a measure that if i select a fiscal year in slicer it gives me the sum of saldo of the previous year but i cant use the previous year functie because the way i have the data