Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello Community!
I need to implement multiple filters in a calculate function, currently I have a measure that sums the amount ([sumVenta]) of the table for example. I need the next filter.
Var vrAnio = 2020
calculate([sumVenta], (TABLE1[Type] ? A && Year - TABLE1[vrAnio]) || (TABLE1[Type] ? B && TABLE1[Year] in 'vrAnio ' vrAnio-1')
That is, if it is type "A" it takes into account the selected year, but if it is of type "B" it takes into account the selected year and the previous year.
TABLA1
| guy | year | amount |
| A | 2020 | 200 |
| B | 2020 | 150 |
| A | 2019 | 300 |
| B | 2019 | 400 |
Thank you very much for your help!
Solved! Go to Solution.
Hi @Syndicate_Admin ,
Here are the steps you can follow:
1. Create measrue.
Measure =
var _selectyear=SELECTEDVALUE('Table'[year])
var _guy=CALCULATE(MAX('Table'[guy]),FILTER('Table','Table'[year]=_selectyear))
return
IF(MAX('Table'[guy])="A",
CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=_selectyear&&[guy]=MAX('Table'[guy]))),
CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),AND(OR('Table'[year]=_selectyear ,'Table'[year]=_selectyear-1),[guy]=MAX('Table'[guy])))))
2. Result.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Syndicate_Admin ,
Here are the steps you can follow:
1. Create measrue.
Measure =
var _selectyear=SELECTEDVALUE('Table'[year])
var _guy=CALCULATE(MAX('Table'[guy]),FILTER('Table','Table'[year]=_selectyear))
return
IF(MAX('Table'[guy])="A",
CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=_selectyear&&[guy]=MAX('Table'[guy]))),
CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),AND(OR('Table'[year]=_selectyear ,'Table'[year]=_selectyear-1),[guy]=MAX('Table'[guy])))))
2. Result.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
// For naming conventions and formatting in DAX,
// please refer to this:
// https://www.sqlbi.com/articles/rules-for-dax-code-formatting/
[Meas] =
var SelectedYear = SELECTEDVALUE( T[Year] )
var SelectedType = SELECTEDVALUE( T[Type] )
var Years_ = {
SelectedYear,
SelectedYear - INT( SelectedYear = "B" )
}
var Filter_ =
TREATAS(
Years_,
T[Year]
)
var Result =
CALCULATE(
[sumVenta], // badly named measure
Filter_
)
RETURN
Result
Friends I leave them as I solved it using a measure
MontoTotal ?
Var vrAnio s 2020
var vrRR ? CALCULATE( sum(TABLA1[Amount]), TABLE1[Type]"A", TABLE1[Year]) in .
var vrRP ? CALCULATE( sum(TABLA1[Amount]), TABLE1[Type]-"B", TABLE1[Year])-vrAnio)
return vrRR + vrRP
I don't know if it's the most optimal, but I'll leave them
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.