Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I'm trying to create a dynamic measure that can be configured using a drop-down. This way someone can choose the period over which to sum sales. I already got this working with Month / MQT / MAT, by using the following measure:
# Sales = CALCULATE(
[Total Sales],
DATESINPERIOD(
'Date'[Date];
MAX('Date'[Date]);
SELECTEDVALUE(Period[offset]);
MONTH
)
)IF( condition = true; DATESYTD(....); DATESINPERIOD(...); )
Solved! Go to Solution.
@Anonymous wrote:
Unfortunataly it seems I can't use an IF statement like this, since that will result in an error "A function 'FILTER' has been used in a True/False expression that is used as a table filter expression". Do I need to do this differently?
Both DATESYTD and DATESINPERIOD return tables and unfortunately you can't return a table value from the IF function. So you will need to put your calculate inside the IF so that it is returning a scalar value.
eg.
# Sales =
IF(
condition = true;
CALCULATE(
[Total Sales],
DATESYTD( ... )
);
CALCULATE(
[Total Sales],
DATESINPERIOD( ... )
);
)
@Anonymous wrote:
Unfortunataly it seems I can't use an IF statement like this, since that will result in an error "A function 'FILTER' has been used in a True/False expression that is used as a table filter expression". Do I need to do this differently?
Both DATESYTD and DATESINPERIOD return tables and unfortunately you can't return a table value from the IF function. So you will need to put your calculate inside the IF so that it is returning a scalar value.
eg.
# Sales =
IF(
condition = true;
CALCULATE(
[Total Sales],
DATESYTD( ... )
);
CALCULATE(
[Total Sales],
DATESINPERIOD( ... )
);
)
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 57 | |
| 55 | |
| 42 | |
| 16 | |
| 16 |
| User | Count |
|---|---|
| 113 | |
| 108 | |
| 38 | |
| 35 | |
| 26 |