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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors