Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

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

  • Anonymous , 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))

    • Anonymous's avatar
      Anonymous
      Not applicable

      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. 

      • parry2k's avatar
        parry2k
        Icon for Super User rankSuper User

        Anonymous 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!

  • Anonymous 

     

    are you using date slicer from your data table?

    • Anonymous's avatar
      Anonymous
      Not applicable

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

      • parry2k's avatar
        parry2k
        Icon for Super User rankSuper User

        Anonymous 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?