Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Current Reporting Month To be shown in Card

I have the data from May 2023 to till date and I need to show the average current month data in the card visual. Data will have the Transaction date, Adoption % and the store list. The report will be refreshed on a daily basis, but it have data 1 week prior to the current week. (If the report is refreshed on 3rd June, the data available in the report is 26th may to 1st June but we consider that as 26th May data).  The requirement is showing recent month data, I used the Current Month formula to show the data it worked perfectly until May 31st, when it refreshed on June 1st it shows no data available.
I need help to show the current month data in the card visual with the available data in the report.
For example, Data available in the report till May 2024 when the data refreshed on 1st June it has to show the current available data (Month).

Used Dax = 

Current Month = CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER('Adoption Trend_Dup', MONTH('Adoption Trend_Dup'[TxnDt]) = MONTH(NOW()) && YEAR('Adoption Trend_Dup'[TxnDt]) = YEAR(NOW())))
 
 
StoreNameStoreNoTxn DtNew Adoption
AA115th May 202410
BB225th May 202420
CC335th May 202430
AA1112th May 202450
BB2212th May 202410
CC3312th May 202425
AA1119th May 2024100
BB2219th May 202495
CC3319th May 202436
AA1126th May 202455
BB2226th May 202466
CC3326th May 2024100
Total   49.75
    
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    I think this happens because you have data from multiple years.

    The following DAX expression does not take the year into consideration, the maximum month is 6, and the data for 2023 and 2024 are calculated.

    The Table data is shown below:

    Use the following DAX expression to create a measure

    Measure = 
    VAR _summarizeTable = ADDCOLUMNS(SUMMARIZE('Table','Table'[Txn Dt],"average",AVERAGE('Table'[New Adoption])),"month",MONTH([Txn Dt]),"year",YEAR([Txn Dt]))
    VAR _maxMonthNumber = MONTH(MAX('Table'[Txn Dt]))
    VAR _maxYearNumber = YEAR(MAX('Table'[Txn Dt]))
    VAR _rowscount = COUNTROWS(FILTER(_summarizeTable,[month] = _maxMonthNumber && [year] = _maxYearNumber))
    VAR _averageOfNewAdoption = SUMX(FILTER(_summarizeTable,[month] = _maxMonthNumber && [year] = _maxYearNumber),[average])
    RETURN DIVIDE(_averageOfNewAdoption,_rowscount,0)

    Final output

    If the error persists, can you share the .pbix file without the sensitive data?

     

    Best Regards,
    Wenbin Zhou
    If this post helps,Please mark me and jgeddes  as the solution.

19 Replies

  • You can try the following and see if it gives you your desired result.
    Instead of MONTH(NOW()) and YEAR(NOW()) you can use MONTH(MAXX(ALL('Adoption Trend_Dup'), [TxnDt])) and YEAR(MAXX(ALL('Adoption Trend_Dup'), [TxnDt])).

    This will take the month and year from the max date that exists in your table.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello,

      Thank you for the reply, i have tried the DAX, it didnt worked. 

      Current Month = CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER('Adoption Trend_Dup', MONTH('Adoption Trend_Dup'[TxnDt]) = MONTH(MAX(ALL('Adoption Trend_Dup'), 'Adoption Trend_Dup'[TxnDt]))))

      Current Month = CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER('Adoption Trend_Dup', MONTH('Adoption Trend_Dup'[TxnDt]) = MONTH(MAX(ALL('Adoption Trend_Dup'[TxnDt]))))

      Current Month = CALCULATE(AVERAGE('Adoption Trend_Dup'[NewAdoption]), FILTER('Adoption Trend_Dup', MONTH(MAXX(ALL('Adoption Trend_Dup', 'Adoption Trend_Dup'[TxnDt])))))
    • Anonymous's avatar
      Anonymous
      Not applicable

      jgeddes  amitchandak 

      Anonymous 

      Can someone from the group help on this issue please. 

  • If you have your date column formatted as above like '5th May 2024' you will need to change it to an acutal date format for it to work. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      jgeddes 
      I cannot change the format of the data as the report refresh only on weekly basis and it will have only the weekly data. We are using the Power Automate to save the historical data in one of excel which have these format. 
      Is there anything else we can do to make the changes.

      Thank you for understanding!!!

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

        Are you importing the data or is it coming in via Direct Query?