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
topazz11
Helper III
Helper III

calculate value between dates and get variance

Hi,

 I want to calculate the value in Table2 between the StartDate and EndDate in table 2.

After that, I also want to calculate the variance as below.

Could someone help me with this?

Thank you! 

 

pbix file 

 

testask.jpg

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @topazz11 

Try this

(1) create the measures

table2_value = CALCULATE(SUM(Table2[vale]),FILTER(ALLSELECTED(Table2),Table2[type]=MIN(Table1[type]) && Table2[date]>=MIN(Table1[start date]) && Table2[date]<= MIN(Table1[finish date])))
variance = MIN(Table1[value])- [table2_value]

result

vxiaotang_0-1647574061229.pngvxiaotang_1-1647574125780.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @topazz11 

Try this

(1) create the measures

table2_value = CALCULATE(SUM(Table2[vale]),FILTER(ALLSELECTED(Table2),Table2[type]=MIN(Table1[type]) && Table2[date]>=MIN(Table1[start date]) && Table2[date]<= MIN(Table1[finish date])))
variance = MIN(Table1[value])- [table2_value]

result

vxiaotang_0-1647574061229.pngvxiaotang_1-1647574125780.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

TomMartens
Super User
Super User

Hey @topazz11 ,

 

the challenge you are facing has a name - it's called events-in-progress.

This article contains all relevant links: Events-In-Progress | Gerhard Brueckl on BI & Data (gbrueckl.at)

I recommend starting with the article by Jason Thomas.

If you need more guidance, create a pbix file that contains sample data, but still reflects your data model (tables. relationships, calculated columns, and measures). Upload the pbix file to onedrive or dropbox and share the link. If you are using Excel to create the sample data, instead of the manual input method, share the xlsx as well.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartens 

here is the sample data. 

pbix file 

 

I think this measure can calculate the value between the start and finish date...

But, I am not sure how to create variance?? or something better way to do it?

 

Thanks,

Measure = 
CALCULATE (
    SUM ( Table2[Value] ),
    FILTER (
        Table2,
        Table2[Date] >= MIN( Table1[startdate] )
            && Table2[Date] <= MAX ( Table1[finishdate] )
    )
)

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.