Forum Discussion

EricMencarini's avatar
EricMencarini
Frequent Visitor
2 years ago
Solved

Power BI - Refresh Data

  Hello to everyone! Good evening! I would appreciate so much if anyone could help me with this: Context: For everytime that my dashboard have a 'refresh', I have a card that show the date ...
  • danextian's avatar
    2 years ago

    Here's what I am thinking.
    In the query editor, create a query that updates every time a semantic model refreshes. This query contains the refresh datetime.

     

    =DateTimeZone.SwitchZone( DateTimeZone.LocalNow(), 😎 // the service uses UTC this needs to converted to your local timezone. 8 = UTC+8. This query will always be a single row.

     

    In Power Automate, run a query against a dataset.  The query should pickup the refresh datetime from the semantic model + the count of the client. You can simulate a query by creating a CALCULATED table inside Power BI and then transfer the logic to Power Automate. The syntax is similar to that of when using DAX Query or DAX Studio. Here's a sample:

     

    DEFINE
        VAR __MAX =
            MAX ( MaxDateFile[Date] )
        VAR __MAXFILE_DU =
            CALCULATE (
                MAX ( MaxDateFile[Filename] ),
                FILTER (
                    MaxDateFile,
                    MaxDateFile[Date] = __MAX
                        && MaxDateFile[Type] = "DU"
                )
            )
        VAR __MAXFILE_PB =
            CALCULATE (
                MAX ( MaxDateFile[Filename] ),
                FILTER (
                    MaxDateFile,
                    MaxDateFile[Date] = __MAX
                        && MaxDateFile[Type] = "PB"
                )
            )
        VAR __RESULT =
            ROW (
                "Max Date", __MAX,
                "Max File DU", __MAXFILE_DU,
                "Max File PB", __MAXFILE_PB
            )
    
    EVALUATE
    UNION (
        ROW ( "Category", "Max Date:", "Value", FORMAT ( __MAX, "DD MMM YYYY" ) ),
        ROW ( "Category", "DU File:", "Value", __MAXFILE_DU ),
        ROW ( "Category", "PB File:", "Value", __MAXFILE_PB )
    )

     

     

    Use DEFINE when defining variables. Use EVALUATE instead of RETURN.

     

    Append the output to an Excel online table. Connect to the Excel file in Power BI. Load it to the model. Compare the latest count in the Excel file to that of current data.

     

    The gist here is that you must be able to store a snapshot of your data somewhere to be able to make a comparison between the previous state of the data and the current.

    Disclaimer: I am no Power Automate expert but I checked on the connectors and it seems my proposition is possible.