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
stella1215
Frequent Visitor

Link Productx function with time slicer and calculate start from 1

Hello everyone, I have a question about Productx. I have a time period selected, and within the time period, I want to calculate the product of the "ReturnRate" column if there's a 1 in the "Action" column on the same row, ignoring the rows with 0 in "Action" column.
Especially, when I change my time slicer, the calculation should always start from 1 like it is showing as the "ExpectedResult" column.

 

My dax is showing like this:

 

 

 

MyResult = 
CALCULATE (
    PRODUCTX ( test, test[ReturnRate] * test[Action] + ( 1 - test[Action] ) ),
    FILTER ( ALL ( test ), test[Date] <= MAX ( test[Date] ) )
)

 

 

 

 

 

 

But I want the result to look like the ExpectedResult. 

 

DateActionReturnRateMyResultExpectedResult
1/1/202111.0101781.0101781.000000
1/2/202111.0025511.0127551.010178
1/3/202100.9800251.0127551.012755
1/4/202100.9576691.0127551.012755
1/5/202100.9472391.0127551.012755
1/6/202110.9796170.9921121.012755
1/7/202100.9708800.9921120.992112
1/8/202110.9861110.9783330.992112
1/9/202110.9663610.9454230.978333
1/10/202100.9250300.9454230.945423

 

Is there any way to fix my dax and let it also work with my time slicer for different period? Thank you! Any help will be much appreciated!! 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

3 REPLIES 3
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1612487425462.png

 

rfigtree
Resolver III
Resolver III

Havent looked closely, wife wants to watch a tv show with me.

But this is possibly part of your problem.

 

MyResult = 
CALCULATE (
    PRODUCTX ( test, test[ReturnRate] * test[Action] + ( 1 - test[Action] ) ),
    FILTER ( ALL ( test ), test[Date] <= MAX ( test[Date] ) )
)

try

MyResult = 
var MaxDate = max(test[Date])
return
CALCULATE (
    PRODUCTX ( test, test[ReturnRate] * test[Action] + ( 1 - test[Action] ) ),
    FILTER ( ALL ( test ), test[Date] <= MaxDate ) )
)

 

Haha you are definitely a great husband! But I don't think adding a variable fixed my problem tho ;-;

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.