Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Aggregation Table Not Working with Year Filter in Power BI

I've encountered an issue with my Power BI report where an aggregation table is not being utilized correctly when I apply a year filter in my visual. I would appreciate any insights or advice on how ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    I've come to a workaround, mainly because, as far as I could understand the engine does not work how I imagined it.

    Your aggregation table must encompass the full dataset of the facts table. Even though the engine is very good, he's not able of switching between AGG and Facts table, if the AGG does not have all of the required timeframe.


    The solution was to create a data model based on a hot and cold direct query:


    The HOT DQ will encompass data from the last 2 years, while the COLD DQ will encompass data prior to the last 2 years.


    I've had to make a few adjustments on the measures I've created, for example:

     

    Measure =
     DIVIDE(
      CALCULATE(
       COUNT(HOT_cci_gpmt_ecommerce_global[article]),
       HOT_cci_gpmt_ecommerce_global[has_discount] = 1
     ),
      CALCULATE(COUNT(HOT_cci_gpmt_ecommerce_global[article]))
     )
     +
     IF(
       MIN(Dim_Calendar[date]) < [_min_updated_date],
       DIVIDE(
        CALCULATE(
         COUNT(COLD_cci_gpmt_ecommerce_global[article]),
         COLD_cci_gpmt_ecommerce_global[has_discount] = 1
       ),
        CALCULATE(COUNT(COLD_cci_gpmt_ecommerce_global[article]))
     )
    )

     

    The measure containing the _threshold_date, required to evaluate if the consulting of the COLD DQ is required:

     

    _threshold_date =
     CALCULATE(
      MIN(HOT_cci_gpmt_ecommerce_global[report_date]),
      ALL(Dim_Calendar)
     )

     


    This way:
    * if the user selects the last 2 years, the AGG is hit;
    * if the user selects a timeframe prior to the last 2 years, the COLD DQ is hit;
    * if the user selects a timeframe encompassing the last 4 years (for instance), both the AGG and COLD DQ are hit.


    Hope i was able to explain it well, and thank you for the help!