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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Pra2010Gha
Frequent Visitor

Dax command to get the values based on paramter date

Pra2010Gha_0-1761942065006.png

Hi I want  a dax command to get the values highlighted based on transaction date parameter.

Say a customer who did a transaction on 18th october and comes back to return those products  on 30 October.

I want the dax to get the date price change that has happened before the transaction date .SO that I can return the amount he paid for the products when the price changed happened and not to over pay him

In this case I want to return the amount 3.5 +6 = $ 9.5 and not 4+7 = $11 (this would be the price on 30th October)

9 REPLIES 9
v-hashadapu
Community Support
Community Support

Hi @Pra2010Gha , hope you are doing great. May we know if your issue is solved or if you are still experiencing difficulties. Please share the details as it will help the community, especially others with similar issues.

Praful_Potphode
Responsive Resident
Responsive Resident

HI @Pra2010Gha ,

 

try below measure:

Return Amount = 
VAR TransactionDate = [transaction date]  -- Your parameter date (10/18/2025)
VAR CurrentProduct = SELECTEDVALUE('YourTable'[product])

VAR CorrectPrice = 
    CALCULATE(
        MAX('YourTable'[base price]),
        FILTER(
            ALL('YourTable'),
            'YourTable'[product] = CurrentProduct &&
            'YourTable'[date price change] <= TransactionDate
        )
    )

RETURN
CorrectPrice
Total Return Amount = 
VAR TransactionDate = [transaction date]  -- 10/18/2025

RETURN
SUMX(
    VALUES('YourTable'[product]),
    VAR CurrentProduct = 'YourTable'[product]
    VAR CorrectPrice = 
        CALCULATE(
            MAX('YourTable'[base price]),
            FILTER(
                ALL('YourTable'),
                'YourTable'[product] = CurrentProduct &&
                'YourTable'[date price change] <= TransactionDate
            )
        )
    RETURN CorrectPrice
)

Create one more  measure to get transaction date as input from slicer/parameter and use it in above measures

 

Thanks and Regards,

Praful

 

 

v-hashadapu
Community Support
Community Support

Hi @Pra2010Gha , Thank you for reaching out to the Microsoft Fabric Community Forum.

 

I reproduced the scenario on my end using sample data and it worked successfully. To help you better understand the implementation, I’ve attached the .pbix file for your reference. Please take a look at it and let me know your observations.

 

Thank you for being part of the Microsoft Fabric Community!

Can some one please add a date parameter to the above pbix file.I tried adding and its not working properlyThanks

Hi @Pra2010Gha , Thanks for reaching out to the Microsoft fabric community forum.

 

I have created a new .PBIX file based on your requirements. Instead of using field parameters, I used a slicer for the date column, as field parameters are not the most suitable option here.
 

On page 1 of the report, you can use the slicer—set it to 18th Oct to get the desired output, which is 3.5 + 6 = $9.5. On page 2, I added a table with a DAX measure to show the price of the fruits on the transaction date. You can use whichever option works best for you. 

 

vhashadapu_1-1762426265270.jpeg

 

Please refer to the attached .pbix file for more details and let me know if you have any further questions.
Thank you.

Hey Thank you for your reply.It looks like the transaction Date(18 oct) is harcoded in your logic...Will it work if I pass a date parameter there?

Pra2010Gha_0-1762179138593.png

 

Also is there a way that it will only filter out the yellow rows and not all the rows? based on the transaction date (parameter date input)?

 

parry2k
Super User
Super User

@Pra2010Gha do you have a separate table for transaction date selection? If yes, does it have a relationship with the price change table? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

No I dont..It will be just the table I mentioned above

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.