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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Eyal
Helper II
Helper II

Measure to calculate based on previous data point.

 

Hello, I need to multiply to parameters. One of which is sampled every 3 days and I need to use the previse sampled point for today calculation until a new sample point arrive, (See screen clip). So for day 02/01/17 calculate 20*1000.

The calculation is:

Product of day parameters = calculate(PRODUCTX(Table2,Table2[PARA1]*Table2[Sample]),Table2[Day])

 

I thought that EARLIER should provide the answer but could not get is to work.

 

Thanks

Eyal

 

ELISA BI.png

1 ACCEPTED SOLUTION

Hi @Eyal

 

Following DAX formula will do the job

Product Of Day Parameters=
VAR PreviousSample =
    IF (
        ISBLANK ( Table1[Sample] ),
        CALCULATE (
            LASTNONBLANK ( Table1[Sample], Table1[Sample] ),
            FILTER ( Table1, Table1[Day] < EARLIER ( Table1[Day] ) )
        ),
        Table1[Sample]
    )
RETURN
    Table1[PARA2] * PreviousSample


LastNonBlank.jpg


Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=calculate(PRODUCTX(Table2,Table2[PARA1]*IF(ISBLANK(Table2[Sample]),CALCULATE(SUM(Table2[Sample]),PREVIOUSDAY(Table2[Day])),Table2[Sample])),Table2[Day])

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

HI Ashish_Mathur

 

tried your solution but did not get the correct result..

Thanks any way/

Eyal

Hi @Eyal

 

Following DAX formula will do the job

Product Of Day Parameters=
VAR PreviousSample =
    IF (
        ISBLANK ( Table1[Sample] ),
        CALCULATE (
            LASTNONBLANK ( Table1[Sample], Table1[Sample] ),
            FILTER ( Table1, Table1[Day] < EARLIER ( Table1[Day] ) )
        ),
        Table1[Sample]
    )
RETURN
    Table1[PARA2] * PreviousSample


LastNonBlank.jpg


Regards
Zubair

Please try my custom visuals

Hi Zubair_Muhammad

 

thanks a lot work like a charm.

 

Eyal

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.