Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Please help me with this dax forumle

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 :):):)
1 ACCEPTED SOLUTION

Hi @Anonymous 

you can manually insert a single column table that contains the years. Let's call it 'YearFilter' which will be completely disconnected from any other table in your data model. This table will be used as a slicer and the measure would be

SumMeaaure =
VAR CurrentYear =
    SELECTEDVALUE ( 'YearFilter'[Year] )
RETURN
    CALCULATE (
        SUM ( '2 (Auditfile)'[saldo] ),
        '2 (Auditfile)'[fiscalYear] >= CurrentYear - 1
    )

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hello why not use previous year? 

Calculate(sum(tabble[value]),previousyear([date]))

Anonymous
Not applicable

becasue that doesnt work for me the way my data is build :(:(:( it would be the  easy way i know but i have the bad luck i have to fix a working repot :S

Anonymous
Not applicable

Hmm well when you select a slicer the range becomes only for the slicer so try the removefilters function? 

 

CALCULATE(SUM('2 (Auditfile)'[saldo]), IF(VALUES('2 (Auditfile)'[fiscalYear])>2018,[fiscalyear]-1),removefilters(dateyouuseforslicer))

Anonymous
Not applicable

if i use your formule i get this error Schermafbeelding 2022-10-21 130939.png

tamerj1
Super User
Super User

Hi @Anonymous 

would you please explain what are you trying to achieve by the IF statement in your DAX code?

Anonymous
Not applicable

Hey tamerj1

i'm trying to archieve a calculation in a card visual, if i select 2019 in a slicer i want the sum of saldo from 2018
if i select 2020 in a slicer i want the sum of saldo from 2019 and so on

i know the if statement works for -1 on the year

Hi @Anonymous 

you can manually insert a single column table that contains the years. Let's call it 'YearFilter' which will be completely disconnected from any other table in your data model. This table will be used as a slicer and the measure would be

SumMeaaure =
VAR CurrentYear =
    SELECTEDVALUE ( 'YearFilter'[Year] )
RETURN
    CALCULATE (
        SUM ( '2 (Auditfile)'[saldo] ),
        '2 (Auditfile)'[fiscalYear] >= CurrentYear - 1
    )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.