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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Ghuiles
Advocate IV
Advocate IV

Latest commentary based on month and country selection

Hello

 

I think i am struggling with something simple.

 

I have a table with Comments

DateRegionComment
1/09/2019EuropeBetter sales on market A
1/10/2019AsiaStrong demand on X
1/10/2019EuropeNtd

 

This table is linked to a DimDate table.

The comments are provided only per month.

 

So, in DAX, how can i show the comments only for the latest month selected?

At the end the user should see either one comment for one region, or if several regions then several comments.
I think that the best object is a table or a matrix.

 

I tried to build something with MAXDimDate[Date]) or MAX(DimDate[YearMonth]) and VALUES but it did not work.

What i am missing?

 

Thanks in advance for your help. G.

2 ACCEPTED SOLUTIONS
v-yuta-msft
Community Support
Community Support

@Ghuiles ,

 

Create a measure using dax as below, please refer to the attached pbix file.

Selected Date = IF(CALCULATE(MAX('Dimension'[Date]), ALLSELECTED('Dimension')) = MAX('Fact'[Date]), MAX('Fact'[Date]))

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

Hello!

 

@v-yuta-msft many thanks for your idea! I managed to build on that with EOMONTH to get the months flattened, and it works now as desired 🙂

 

At the end the formula looks like: 

IF(CALCULATE(EOMONTH(MAX('DimDate'[Date]),0), ALLSELECTED('DimDate')) = EOMONTH(MAX('Sales Comments'[Date]),0), eoMONTH(MAX('Sales'Comments'[Date]),0))
 
Cheers. G.

View solution in original post

5 REPLIES 5
v-yuta-msft
Community Support
Community Support

@Ghuiles ,

 

Create a measure using dax as below, please refer to the attached pbix file.

Selected Date = IF(CALCULATE(MAX('Dimension'[Date]), ALLSELECTED('Dimension')) = MAX('Fact'[Date]), MAX('Fact'[Date]))

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

Thanks for your proposal! 🙂

hmm. I think we are close to the solution, but still not fully there.

The user is indeed selecting the month via a slicer on DimDate[Month].

DimDate and the Fact tables are linked via the field [Date], so not month.

 

Somehow it still does not work 😞

No matter which month it is selected (only September, the full year, all months before Sept etc), the result is blank.

I unfortunately cannot post my model.
Any clue on how to solve this?

 

 

Hello!

 

@v-yuta-msft many thanks for your idea! I managed to build on that with EOMONTH to get the months flattened, and it works now as desired 🙂

 

At the end the formula looks like: 

IF(CALCULATE(EOMONTH(MAX('DimDate'[Date]),0), ALLSELECTED('DimDate')) = EOMONTH(MAX('Sales Comments'[Date]),0), eoMONTH(MAX('Sales'Comments'[Date]),0))
 
Cheers. G.
amitchandak
Super User
Super User

When you say a latest selected month. So once filter on a month of your date then you will get that month data.

 

Can you share sample data and sample output. Thanks.
Proud to be a Datanaut My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi!

The problem is that the user can select for example Jan, Feb, March. But we would like to see only the comments related to March.

Best regards. G.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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