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
Pratik1802
Regular Visitor

Create a measure to get the entire month value based on selected date.

Hi, I am trying to build a report which needs a DAX that I am having some trouble with. 

 

I have a table which has the following structure:

Pratik1802_0-1685829184710.png

I want to create a report using a matrix visual that looks like:

Pratik1802_1-1685829238750.png

The issue that I am facing is wit hthe Month Amount_EUR measure. The user is going to select any 1 date (Invoice date) in th date slicer and then based on that the report should show the Month Amount for that entire month. One more point to note is that there may not be any invoice created for a specific country- legal entity pair for that selected date but there many by a value for some other date in that month. So in this case as well we should get the month amount_eur value. 

 

Any helo would be much appriciated and if you need more information or something is not clear please let me know.

 

Thanks!

 

 

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

Hi @Pratik1802 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1685946541742.png

(2) We can create a table and a measure. 

vtangjiemsft_1-1685946850924.png

 

Table 2 = VALUES('Table'[INVOICE_DATE])
month amount_eur = 
 var _a=SELECTEDVALUE('Table 2'[INVOICE_DATE])
 var _b= CALCULATE(SUM('Table'[Today Amount_Eur]),FILTER(ALL('Table'),'Table'[COUNTRY_ID]=MAX('Table'[COUNTRY_ID]) && 'Table'[LEGAL_ENTITY_ID]=MAX('Table'[LEGAL_ENTITY_ID]) && YEAR('Table'[INVOICE_DATE])=YEAR(_a) && MONTH('Table'[INVOICE_DATE]) =MONTH(_a)))
 return _b

(3) Then the result is as follows.

vtangjiemsft_2-1685946897405.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @Pratik1802 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1685946541742.png

(2) We can create a table and a measure. 

vtangjiemsft_1-1685946850924.png

 

Table 2 = VALUES('Table'[INVOICE_DATE])
month amount_eur = 
 var _a=SELECTEDVALUE('Table 2'[INVOICE_DATE])
 var _b= CALCULATE(SUM('Table'[Today Amount_Eur]),FILTER(ALL('Table'),'Table'[COUNTRY_ID]=MAX('Table'[COUNTRY_ID]) && 'Table'[LEGAL_ENTITY_ID]=MAX('Table'[LEGAL_ENTITY_ID]) && YEAR('Table'[INVOICE_DATE])=YEAR(_a) && MONTH('Table'[INVOICE_DATE]) =MONTH(_a)))
 return _b

(3) Then the result is as follows.

vtangjiemsft_2-1685946897405.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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.

Top Solution Authors