Forum Discussion

jostnachs's avatar
jostnachs
Helper IV
1 year ago

YTD Slicer

Hi All, I have a requirement where i have to have YTD slicer. i.e. if i select June 2025, the table should populate values from Jan-25 till June-25 , if I select feb-24, the table should populate values from Jan-24 till feb-24. 

After researching, i ama able to acheive this by creating a duplicte dte table and having a passive relationship and using measure. But i have an issue when  I try to use it with other fields in a table. the table just breaks. the moment i add premium and commission in the table

VAR SelectedDate = MAX('Month Accounting'[MonthEndDate])  
VAR SelectedYear = YEAR(SelectedDate)  
VAR SelectedMonth = MONTH(SelectedDate)
VAR FirstDateOfYear = DATE(SelectedYear, 1, 1)  
VAR Result =
    CALCULATE(
        [Current Company Revenue],  
        REMOVEFILTERS('Month Accounting'),  
        'Month Accounting'[MonthEndDate] >= FirstDateOfYear,  
        'Month Accounting'[MonthEndDate] <= SelectedDate,  
        USERELATIONSHIP('Date'[MonthEndDate], 'Month Accounting'[MonthEndDate])  
    )

RETURN Result

 

 

9 Replies

    • jostnachs's avatar
      jostnachs
      Helper IV

      Thank you for sharing this...

      I tried this too changing my relationship from Month accounting to the fact table. but the behaviour is same the table breaks saying query exceeding resources the moment i use the measure in the table along with other.

      Commission_UpToSelectedDate1 =
      VAR SelectedDate = MAX('Month Accounting'[MonthEndDate])  
      VAR SelectedYear = YEAR(SelectedDate)  
      VAR SelectedMonth = MONTH(SelectedDate)
      VAR FirstDateOfYear = DATE(SelectedYear, 1, 1)  
      VAR Result =
          CALCULATE(
              [Current Company Revenue],  
              REMOVEFILTERS('Month Accounting'),  
              'Month Accounting'[MonthEndDate] >= FirstDateOfYear,  
              'Month Accounting'[MonthEndDate] <= SelectedDate,  
              USERELATIONSHIP('Date'[MonthEndDate], _Production[D_AccountingMonth])  
          )

      RETURN Result
      • v-echaithra's avatar
        v-echaithra
        Community Support

        Hi jostnachs ,

        Thank you for the update. 

        The issue occurs when a visual has attempted to query too much data for the server to complete the result with the available resources.

        As suggested in the error, you may need to try filtering the visual to reduce the amount of data in the result currently. there is limit. Apply data-point limits and strategies by visual type 

         

        And you can follow the tips to optimize your report:

        1.Do not expose in a view a column that is not necessary in the Power BI data model.

        2.Optimize the DAX calculation used in this visual to use less memory and return faster or change what the visual displays.

        3.Remove unnecessary precision or split granularity values to reduce cardinality(Significantly reduce highly unique datetime values by splitting the date and time into separate columns. )

        Reference: Chris Webb's BI Blog: The “Visual Has Exceeded The Available Resources” Error In Power BI

        If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

        Thanks,
        Chaithra E.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi jostnachs ,

    May I ask if you have gotten this issue resolved?

     

    If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

     

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi jostnachs ,

    We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi jostnachs ,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.

  • Different issue and not sure how to debug this.....I have a heirarchy used in a mtrix and the selecction of the date is not giving YTD for the regions where its blank 

    Like the screenshot shows only jun25 as it has data only for june25 not sowing may 25... if i select aug25 its empty not bringing June25 too 

    any help here please

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi jostnachs ,

    I’ve created a measure based on your requirement and tested it using sample data. It appears to be working as expected on my end.

    Please refer to the attached pbix file for details. If you're still encountering issues, kindly share your sample data or model structure so I can further investigate and help troubleshoot the problem more accurately.

    Best Regards,
    Chaithra E.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi jostnachs ,

    We would like to confirm if you've successfully resolved this issue or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.

    Thank you for your patience and look forward to hearing from you.

    Best Regards,
    Chaithra E.