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
frknklcsln
Helper II
Helper II

how to set a what if parameter for a date field

Hi,

 

I want to create a parameter for a date field. The user will choose the date range, and my calculations will change according to it.

 

frknklcsln_0-1661510766132.png

 

The date range will actually be depending on a certain column from my table. How can I achieve this

 

SUMMARIZE(
    FILTER(
        '10-CSV',
        '10-CSV'[Actual Date for End] <> BLANK() &&
        AND('10-CSV'[Actual Date for End] >= EOMONTH(TODAY(), -2),
        '10-CSV'[Actual Date for End] <= EOMONTH(TODAY(), -1 )),
I will change my dax to below:
 
SUMMARIZE(
    FILTER(
        '10-CSV',
        '10-CSV'[Actual Date for End] <> BLANK() &&
        [Date Parameter] ),
 
So, the calculation will be filtered by the user.
 
 
When I create the parameters with numeric range. I should convert this 48123 kind of date info to a normal date format like 12/05/2022. 
 
Any ideas?
 
 
7 REPLIES 7
lbendlin
Super User
Super User

It's not really worth trying to bend the What-If parameters like this.  Use a disconnected dates table with the appropriate range and feed the date range slicer from that.  Then use SELECTEDVALUE() in your measures.

Hi @lbendlin , thank you for your answer.

 

I created 2 date table without relation. One for is start date, the other one is end date. Then I created measures as

 

Start Date = SELECTEDVALUE('Date Table2'[Date])

End Date = SELECTEDVALUE('Date Table3'[Date])

 

Then I added these measure to the filter in my main DAX like below:

 

 

'10-CSV'[Actual Date for End] <> BLANK() &&

        '10-CSV'[Actual Date for End] >= [Start Date] &&

        '10-CSV'[Actual Date for End] <= 'Date Table3'[End Date] &&

 

But it doesn't work. 

 

What am I doing wrong?

Create a single Dates table. Feed a range slicer from it. Use the MIN() and MAX() values in your measure.

Hi,

 

I created a data table with single column. Then I wrote measures with MIN and MAX as you said.

 

frknklcsln_0-1661933895749.pngfrknklcsln_1-1661933902558.png

But when I added these measure in filters, it doesnt work.

 

 

SUMMARIZE(

    FILTER(

        '10-CSV',

        '10-CSV'[Actual Date] <> BLANK() &&

        AND('10-CSV'[Actual Date for End]>= [Start Date],

        '10-CSV'[Actual Date for End]<= [End Date]) &&

        '10-CSV'[Air] =1),

 

It takes the all none blank values. 

 

 

I created a column Column = [Start date] to see which date the measure was taking.

 

frknklcsln_2-1661934416660.png

 

It looks like when i change the range, it doesnt apply. Start date measure will take the MIN value of the whole date table, not the one selected. Any idea?

Your approach seems reasonable.  Are you sure you used measures and not calculated columns?

 

Try 

 

SUMMARIZE(
    FILTER(
        '10-CSV',
        '10-CSV'[Actual Date] <> BLANK() &&
        '10-CSV'[Actual Date for End]>= min('Date Table2'[Date]) &&
        '10-CSV'[Actual Date for End]<= max('Date Table2'[Date]) &&
        '10-CSV'[Air] =1),

 

 

Hi @lbendlin , yes, I am sure I am using measure.

 

When I did like yours, it doesnt apply too.

 

My main DAX is virtual table actually. Do you think that may be the reason behind it?

 

Virtual table =

var _table1=

SUMMARIZE(
FILTER(
'10-CSV',
'10-CSV'[Actual Date for End] <> BLANK() &&
AND('10-CSV'[Actual Date for End]>= MIN('Date Table2'[Date]),
'10-CSV'[Actual Date for End]<= MAX('Date Table2'[Date])) &&
'10-CSV'[Air] =1),
'10-CSV'[ID],
.
.
.
var _ table2=
.
.
.

Virtual tables (table variables) can only live inside a measure, as part of the computation. What you probably did was create a calculated table. These are immutable.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors