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
Kgathright
Helper II
Helper II

Help with measure for extracting max date

Hello!

I am tasked with extracting a max posting date from a dataset in our PowerBI dashboard. 

The available date range on the slicer page is back 3 months to date. If they move the slicer to within the last week one of the card counts displays blank. This is because there is no data for the current week. 
When this happens I need to display the max posting date to the card in place of  'blank'.  Since all of data I need is there, adding updated sql to remove restriction on posting dates isn't an option. This dashboard is arleady a beast. I have to find a way to display the max posting date for the cust_num specificed while ignoring the slicer dates. Make sense? 

 

Here is a sample of my dataset: 

ACCOUNT_EMPLOYEE_IDEMPLOYEEPOSTING_DATECUST_NUM
555111|34400001002020/05/10 00:00:00555111
555111|50000001012020/05/10 00:00:00555111
555111|55555551022020/05/10 00:00:00555111
555111|44444441032020/05/10 00:00:00555111
555111|33333331042020/05/10 00:00:00555111
555111|22222221052020/05/10 00:00:00555111
555111|00000001062020/05/10 00:00:00555111
555111|11111111072020/05/10 00:00:00555111
555111|22222211082020/05/10 00:00:00555111
555111|787878781092020/05/10 00:00:00555111
555111|989898981102020/04/19 00:00:00555111
555111|878787871112020/04/19 00:00:00555111
555111|111122551122020/04/19 00:00:00555111
555111|114455661132020/04/19 00:00:00555111
555111|114433221142020/04/19 00:00:00555111
555111|110099881152020/04/19 00:00:00555111

 

I have this which works beautifully when there is data returned: 

 

Max_Posting_Date = if(([EmployeeCount_Measure1]=0 || ISBLANK([EmployeeCount_Measure1])=TRUE),MAX(ACTRANS_Turnover[POSTING_DATE]),0)
 
12 REPLIES 12
amitchandak
Super User
Super User

@Kgathright , you have to replace you max date with these

 

calculate(MAX(ACTRANS_Turnover[POSTING_DATE]),all(Date))

or

calculate(MAX(ACTRANS_Turnover[POSTING_DATE]),all(ACTRANS_Turnover))

This is definitely a step in the right direction as I'm no longer seeing blank which is great thank you so much. 

 

How can I specify the max date for the specified CUST_NUM in the slicer - meaning the max date displaying is 5/3/2020 but I happen to know it's 5/10/2020 becuase I'm running the SQL manually for data validation. 

@Kgathright try this

 

Max date = CALCULATE ( MAX ( Table[PostingDate] ), ALLEXCEPT ( Table, Table[Customer] ) )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

This is what I ended up using: 

 

Max_Posting_Date = calculate(MAX(ACTRANS_Turnover[POSTING_DATE]),all('Accounting Calendar'[FullDate]))

I found a defect with this logic due to a unit test scenario: 

 

I have a Report Date Range and an Available Date Range on the slicer page. End user wants to check February numbers, my max posting date is 5/20 as it is the max date available in the dataset, so it is doing exactly what I asked since the dataset incorporates the Available Date Range which is three months back. 

 

How do I get the max date that falls within the Report Date Range? 

 

 

Nevermind! Once I stepped away and came back the solution was obvious to me! 

 

Max_Posting_Date = CALCULATE(MAX(ACTRANS_Turnover[POSTING_DATE]),ALL('Accounting Calendar'[ReportEndDate]))
 
 
parry2k
Super User
Super User

@Kgathright 

 

are you using date slicer from your data table?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

The data slicer is using Accounting Calendar table, to which I have access 

@Kgathright so you have a calendar dimension in your model that is connected to your data table and you are using date from calendar dimension? Is this a correct understanding?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

The dataset I'm supposed to get this max date from isn't connected to the Accounting Calendar table. The posting_date date ranges are hardcoded in the SQL. 

@Kgathright there are lot of moving parts, you need to share 

 

- how you are tables are connected

- what you are using for slicers

- where you want the max date from

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

slicers are using the Accounting Calendar table

 

dataset in which the max date should come from isn't connected to the Accounting Calendar table it is connected to another table using the ACCOUNT/EMPLOYEEID

 

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.