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

How to specify the level of a measure

I have two tables. One with the hours of actual learning of the students (per month) and one with the expected learning of the student (per week). I would like to know how to calculate the difference between the two tables (Expected Learning - Actual Learning), but specifying the level which means that I would like this to happen for every month. 

 

In other words, this should be something like this for each month:

Sum of weeks(Expected Learning) - Actual Learning

 

Please let me know if you need any other information.

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Fran1991cesco 

According to your description, you want to calcuate the difference between the actual and expected learning. RIght?

Here are the steps you can refer to :
(1)This is my test data :

vyueyunzhmsft_0-1671677122578.png

(2)We can click "New measure" to create two measures like this:

Expected Value = var _curdate= MIN('actual learning'[Date])
var _cur_stu=VALUES('actual learning'[Student])
var _expected_table = FILTER(ALLSELECTED('Expected Learning') , 'Expected Learning'[Student] in _cur_stu && YEAR('Expected Learning'[Date])=YEAR(_curdate) && MONTH('Expected Learning'[Date])=MONTH(_curdate))
return
SUMX(_expected_table,[Value])
Difference = [Expected Value] -SUM('actual learning'[Value])

 

(3)Then we can put the measures on the visual and we can meet your need:

vyueyunzhmsft_1-1671677245120.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

View solution in original post

6 REPLIES 6
Fran1991cesco
Frequent Visitor

Sorry for not being responsive earlier. 

I tried to do what you suggested but it did not work @v-yueyunzh-msft

 

The situation is more slightly more complicated that anticipated which is why I the solution is not yet working. I ma going to provide some screenshots (this might also answer your question @Ashish_Mathur )

Fran1991cesco_0-1671807529740.png 

Fran1991cesco_1-1671807561069.png

 

If I use the formula you provided, I do not get the expected result. 

Fran1991cesco_2-1671807958490.png

Can you please help me @Ashish_Mathur and @v-yueyunzh-msft ?

 

 

 

Hi , @Fran1991cesco 

Thanks for your quick response! Doe the data you provide, i think my dax is right. Why "a" Student in "2022/01" is -15?

vyueyunzhmsft_0-1672016789391.png

In my thought, the actual is 15 and the expected is also 15 using my dax logic:

vyueyunzhmsft_1-1672016804589.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Hi,

Share data in a format that can be pasted in an MS Excel file.


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

 I will thanks for now

Ashish_Mathur
Super User
Super User

Hi,

Share some data (which can be pasted in an MS Excel file) and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yueyunzh-msft
Community Support
Community Support

Hi , @Fran1991cesco 

According to your description, you want to calcuate the difference between the actual and expected learning. RIght?

Here are the steps you can refer to :
(1)This is my test data :

vyueyunzhmsft_0-1671677122578.png

(2)We can click "New measure" to create two measures like this:

Expected Value = var _curdate= MIN('actual learning'[Date])
var _cur_stu=VALUES('actual learning'[Student])
var _expected_table = FILTER(ALLSELECTED('Expected Learning') , 'Expected Learning'[Student] in _cur_stu && YEAR('Expected Learning'[Date])=YEAR(_curdate) && MONTH('Expected Learning'[Date])=MONTH(_curdate))
return
SUMX(_expected_table,[Value])
Difference = [Expected Value] -SUM('actual learning'[Value])

 

(3)Then we can put the measures on the visual and we can meet your need:

vyueyunzhmsft_1-1671677245120.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

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.