Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Icon for Impactful Individual rankImpactful Individual
1 day ago
Solved

dynamic format string live connection issue

i am working on report which is connected live to semantic model stored on power bi service, i am unable to apply dynamic string format (feature as explained in below tutorial ) since it does not work on live connection

i have downloaded the latest copy of semantic model, how do i repoint my report from live to local using import? is there any alternative way to apply dynamic format string without changing or repointing the report to local semantic model? 

https://www.youtube.com/watch?v=s4jeX9EKON4&pp=ygUhZHluYW1pYyBmb3JtYXQgc3RyaW5nIGluIHBvd2VyIGJp

 

  • Hi powerbiexpert22​,

    Dynamic format strings need to be defined in the semantic model, so you can't normally add them directly when using a live connection.

    If you have access to edit the original semantic model, I would recommend making the changes there. Your report can then remain live-connected, and other reports using the same model can benefit from the changes too.

    If you want to work locally, you can open the downloaded PBIX, make the changes, and publish the updated semantic model back to Power BI Service. Just be careful not to overwrite the existing model unintentionally.

    Another option is to select “Make changes to this model” in Power BI Desktop. This creates a local model on top of the remote semantic model, but it doesn't convert the connection to Import mode, and it may not overcome the dynamic format string limitation.

    For reference, see Microsoft's documentation: https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-dynamic-format-strings

3 Replies

  • Hi powerbiexpert22​,

    Dynamic format strings need to be defined in the semantic model, so you can't normally add them directly when using a live connection.

    If you have access to edit the original semantic model, I would recommend making the changes there. Your report can then remain live-connected, and other reports using the same model can benefit from the changes too.

    If you want to work locally, you can open the downloaded PBIX, make the changes, and publish the updated semantic model back to Power BI Service. Just be careful not to overwrite the existing model unintentionally.

    Another option is to select “Make changes to this model” in Power BI Desktop. This creates a local model on top of the remote semantic model, but it doesn't convert the connection to Import mode, and it may not overcome the dynamic format string limitation.

    For reference, see Microsoft's documentation: https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-dynamic-format-strings

  • jubinsoni's avatar
    jubinsoni
    Icon for Continued Contributor rankContinued Contributor

    Hi powerbiexpert22​,

    To answer the "how do I repoint" part directly: the cleanest way is to save the report as a Power BI Project (PBIP) and change the dataset reference in one file. No rebuilding of visuals is needed.

    live-connected report -> File > Save as > Power BI Project (.pbip)
    -> open <Report>.Report\definition.pbir in a text editor
    -> swap "byConnection" (Service model) for "byPath" (local model)
    -> put the downloaded model next to it as <Model>.SemanticModel
    -> reopen the .pbip -> report now runs on the local model
    {
      "version": "4.0",
      "datasetReference": {
        "byPath": {
          "path": "../Sales.SemanticModel"
        }
      }
    }

    The easy way to get the .SemanticModel folder is to open the downloaded PBIX and save it as PBIP too. The visuals keep working as long as table, column and measure names match.

    That said, I would only go local if you have to. If the goal is just the format string, keeping one shared model is better long term. Two ways to add it there without touching the report:

    edit the model in the Service (Open data model / web modeling)
      -> select the measure -> Format: Dynamic -> add the expression
    XMLA endpoint (Premium / Fabric capacity) + Tabular Editor
      -> set the measure's Format String Expression -> save
    -- Format String Expression on the measure
    SWITCH (
        TRUE (),
        ABS ( [Sales] ) >= 1e9, "#,0.0,,,\"B\"",
        ABS ( [Sales] ) >= 1e6, "#,0.0,,\"M\"",
        ABS ( [Sales] ) >= 1e3, "#,0.0,\"K\"",
        "#,0"
    )

    Avoid the FORMAT() measure workaround on a live connection: it returns text, so the values can't be used on chart axes and won't sort numerically.

    So my overall approach would be:

    can edit the shared model? -> add the dynamic format string there
    -> report stays live, every report on the model benefits
    must work locally? -> save as PBIP -> definition.pbir byPath
    -> point it at the downloaded model -> add the format string

    AI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.

  • ShivekMaharaj's avatar
    ShivekMaharaj
    Icon for Community Champion rankCommunity Champion

    Hi powerbiexpert22​,

    I would avoid downloading the semantic model and repointing the report to an Import model just for this.

    A dynamic format string is a property of the measure in the semantic model. If you have access to modify the published semantic model, the cleanest option is to define the dynamic format string on the measure there. Your live-connected report can then continue using the shared semantic model without being repointed.

    Microsoft documents dynamic format strings here: Create dynamic format strings for measures.

    If you do need report-specific model changes and cannot modify the shared semantic model, use Make changes to this model in Power BI Desktop. That adds a local model and changes the connection to DirectQuery against the published semantic model; it does not convert the remote semantic model to Import mode.

    See: Use composite models in Power BI Desktop.

    For formatting that is only needed on a particular visual, visual-level custom format strings may also be enough, but they are not equivalent to a conditional dynamic format string on the measure.

    I would only use FORMAT() as a fallback because it converts the result to text, whereas a dynamic format string keeps the measure numeric.

    So in short: if possible, add the dynamic format string to the shared semantic model. If that is not possible, adding a local model is preferable to duplicating/reimporting the entire semantic model.

    AI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.