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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ILLANA_N
New Member

Dax measure for if date is smaller than maximum selected date from slicer then sumA else SumB

I want to show a matrix table showing actuals if dates is smaller than e.g. 31 May 2025 then budget values if after this date

 

I was using this formula

FORECAST = IF(FIRSTDATE(Budget_data[Date]) <= DATE(2025,05,31),sum('PnL Data_2025'[Amount]),sum(Budget_data[Amount]))

 

but I now want the dashboard user to select a dates on the slicer instead of me hard coding the cut off date.

4 REPLIES 4
v-hjannapu
Community Support
Community Support

Hi @ILLANA_N,

Thank you  for reaching out to the Microsoft fabric community forum.

Thank you so much @Jihwan_Kim, for sharing such a clear and practical solution really appreciate the effort you put into recreating the sample model and measure logic

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the response has addressed your query, please Accept it as a solution so that other community members can find it easily.
Regards,
Harshitha.

Hi @ILLANA_N,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please Accept it as a solution so that other community members can find it easily.


Thank you.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1750215786553.png

 

 

Jihwan_Kim_0-1750215763860.png

 

Expected result measure: = 
VAR _selecteddate =
    SELECTEDVALUE ( 'Calendar slicer'[date], DATE ( 2025, 5, 31 ) )
VAR _pnldata =
    SUM ( 'PnL Data_2025'[amount] )
VAR _budget =
    SUM ( Budget_data[amount] )
VAR _t =
    ADDCOLUMNS (
        VALUES ( 'Calendar'[date] ),
        "@result",
            IF (
                'Calendar'[date] <= _selecteddate,
                CALCULATE ( SUM ( 'PnL Data_2025'[amount] ) ),
                CALCULATE ( SUM ( Budget_data[amount] ) )
            )
    )
RETURN
    SUMX ( _t, [@result] )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
bhanu_gautam
Super User
Super User

@ILLANA_N Create a date slicer in your Power BI report.
Use the SELECTEDVALUE function to get the date selected by the user.

DAX
FORECAST =
VAR SelectedDate = SELECTEDVALUE(DateTable[Date])
RETURN
IF(
SelectedDate <= DATE(2025, 05, 31),
SUM('PnL Data_2025'[Amount]),
SUM(Budget_data[Amount])
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.