Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
tom-lenzmeier
Helper II
Helper II

Dynamic Formatting Error

In my values column in an unpivoted table, I am trying to apply dynamc formatting to amounts and dates. Prior to the unpivot action, I converted the date column to decimal and the amount column is decimal.

I then wrote the following measure: SUM(Agreements[Value])
FORMAT: Dynamic

SWITCH(
    SELECTEDVALUE(UP_PRD_Agreements[Attribute]),
        "Current Price", "$#,##0",
        "EffectiveDate", "MM/dd/yyyy",
        "0")
The current price is correctly formatted but the effective date displays MM/dd/yyyy -- not a date.


I also tried this:
 

Display Value =
VAR _Raw = SUM(UP_PRD_Agreements[Value])
VAR _AttrType = SELECTEDVALUE(UP_PRD_Agreements[Attribute])

RETURN
SWITCH(
_AttrType,
"EffectiveDate", FORMAT(_Raw, "MM/dd/yy"),
"Current Price", FORMAT(_Raw, "$#,##0"),
"Current Price Valid From", FORMAT(_Raw, "MM/dd/yy"),
FORMAT(_Raw, "0")
)

I got an error saying 828738814 is out of range for format string.

 

I'm at my wits end.

 

Thanks in advance!!!!

1 ACCEPTED SOLUTION
Natarajan_M
Solution Supplier
Solution Supplier

Hi @tom-lenzmeier , I just modified the DAX formula you were using and obtained the following result. Can you let me know if this is what you are looking for?

The issue with the sum on the date was causing an overflow error, so I took the maximum value and added it to the date to resolve the problem.



Display Value Fixed = 
VAR _AttrType = SELECTEDVALUE(UP_PRD_Agreements[Attribute])
VAR _Raw      = SUM(UP_PRD_Agreements[Value])
VAR _RawMax   = MAX(UP_PRD_Agreements[Value])

RETURN
SWITCH(
    _AttrType,

    "EffectiveDate",
        FORMAT(
            DATE(1899, 12, 30) + INT(_RawMax),
            "MM/dd/yyyy"
        ),

    "Current Price",
        FORMAT(_Raw, "$#,##0"),

    "Current Price Valid From",
        FORMAT(
            DATE(1899, 12, 30) + INT(_RawMax),
            "MM/dd/yyyy"
        ),

    FORMAT(_Raw, "0")
)


dax :

Natarajan_M_1-1774059048118.png


Fixed dax :

Natarajan_M_2-1774059081119.png

Sample file :
Dynamic Formatting.pbix

Thanks,
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster

 

View solution in original post

8 REPLIES 8
Natarajan_M
Solution Supplier
Solution Supplier

Hi @tom-lenzmeier , Do you mean a slicer based on the attribute?

Natarajan_M_0-1774287047995.png

Thanks 

Natarajan_M
Solution Supplier
Solution Supplier

I'm using the measure to format the values I didn't use the Dynamic formating .

Dynamic format strings are designed for cases where the measure returns a consistent type across all cells.

Thanks,

If you found this helpful, please consider giving it a kudo and marking it as the accepted solution — it goes a long way in helping others facing the same issue.

For more Power BI tips and discussions, let’s connect on LinkedIn:
https://www.linkedin.com/in/natarajan-manivasagan

Cheers!

I understand what you're saying. I'm just trying to get the toggle to work. Right now, nothing happens when I click on either all attributes or changes.

Natarajan_M
Solution Supplier
Solution Supplier

Hi @tom-lenzmeier , I just modified the DAX formula you were using and obtained the following result. Can you let me know if this is what you are looking for?

The issue with the sum on the date was causing an overflow error, so I took the maximum value and added it to the date to resolve the problem.



Display Value Fixed = 
VAR _AttrType = SELECTEDVALUE(UP_PRD_Agreements[Attribute])
VAR _Raw      = SUM(UP_PRD_Agreements[Value])
VAR _RawMax   = MAX(UP_PRD_Agreements[Value])

RETURN
SWITCH(
    _AttrType,

    "EffectiveDate",
        FORMAT(
            DATE(1899, 12, 30) + INT(_RawMax),
            "MM/dd/yyyy"
        ),

    "Current Price",
        FORMAT(_Raw, "$#,##0"),

    "Current Price Valid From",
        FORMAT(
            DATE(1899, 12, 30) + INT(_RawMax),
            "MM/dd/yyyy"
        ),

    FORMAT(_Raw, "0")
)


dax :

Natarajan_M_1-1774059048118.png


Fixed dax :

Natarajan_M_2-1774059081119.png

Sample file :
Dynamic Formatting.pbix

Thanks,
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster

 

Not quite. Based on your earlier response, I have this measure:

VAR _Raw = MAX(UP_PRD_Agreements[Value])
VAR _AttrType  = SELECTEDVALUE(UP_PRD_Agreements[Attribute])

RETURN
SWITCH(
    _AttrType,
    "Effective Date", FORMAT(_Raw, "MMM-dd-yy"),
    "Current Price Valid From", FORMAT(_Raw, "MMM-dd-yy"),
    "Current Price", FORMAT(_Raw, "$#,##0"),
    FORMAT(_Raw, "0")
)
Initially, you gave me this measure, which works in the slicer:
Toggle Display =
VAR _Selection =
    SELECTEDVALUE(
        'Chg Toggle'[ShowFilter],
        "All Attributes"
    )
VAR _IsChg = MAX(UP_PRD_Agreements[IsChanged])
VAR _Value = MAX(UP_PRD_Agreements[Value])
RETURN
    IF(
        _Selection = "All Attributes",
        _Value,
        IF(_IsChg = "Changed", _Value, BLANK())
    )
When you clicked on "All Attributes," all the records are displayed. When you click on "Changes Only," only the changed records are displayed. The formatting in the first one I pasted in looks great.
 
tomlenzmeier_0-1774290505424.png

The slicer is the missing piece:

tomlenzmeier_1-1774290569042.png

In your original response, the matrix had the Toggle Display measure without the formatting. Does this make sense?

 

Hi @tom-lenzmeier ,I do not have the measure "Toggle Display" in the shared Dynamic Formatting PBIX file. I believe you are referring to the other file I shared for the SCD tracking thread.

Dynamic Formatting pbix 

Natarajan_M_0-1774307824988.png
Scd tracking pbix : 

Natarajan_M_1-1774308684065.png

 

Thanks 
If you found this helpful, please consider giving it a kudo and marking it as the accepted solution — it goes a long way in helping others facing the same issue.

For more Power BI tips and discussions, let’s connect on LinkedIn:
https://www.linkedin.com/in/natarajan-manivasagan

Cheers!

I am truly grateful for all of your assistance. I am hopefully only going to call upon you one more time. The slicer I am using, based on your earlier solution, is not behaving correctly. Right now regardless of whether I click on all attributes or changes only, nothing happens. If you recall, I'm hoping that when a user clicks on changes only, they see the non-current/current records and the unchanged ones are not displayed. Here's the data I'm working with. The date values have been converted to integers due to the dynamic formatting.

 

 

 

Base Agreement NumberIsChangedAttributeValueIsCurrentVersion
00159957ChangedCurrent Price110011
00159957ChangedCurrent Price130001
00159957ChangedCurrent Price130012
00159957ChangedCurrent Price143012
00159957ChangedEffective Date4608201
00159957ChangedEffective Date4608211
00159957ChangedEffective Date4610012
00161305UnchangedCurrent Price74511
00161305UnchangedEffective Date4608211
00162285UnchangedCurrent Price5711
00162285UnchangedCurrent Price6011
00162285UnchangedCurrent Price17511
00162285UnchangedEffective Date4608211

 

The dax measure is identical to yours.


Toggle Display =
VAR _Selection =
    SELECTEDVALUE(
        'Chg Toggle'[ShowFilter],
        "All Attributes"
    )
VAR _IsChg = MAX(UP_PRD_Agreements[IsChanged])
VAR _Value = MAX(UP_PRD_Agreements[Value])
RETURN
    IF(
        _Selection = "All Attributes",
        _Value,
        IF(_IsChg = "Changed", _Value, BLANK())
    )

Ok, when I drop DisplayValue in the matrix, it works. The measure I had been using (Display) didn't work in the slicer. Your code works, but your solution seems to be based on the measure and not the formatting? If I apply your code to the dynamic formatting, things go awry.

 

Toggle Display =
VAR _Selection =
    SELECTEDVALUE(
        'Chg Toggle'[ShowFilter],
        "All Attributes"
    )
VAR _IsChg = MAX(UP_PRD_Agreements[IsChanged])
VAR _Value = MAX(UP_PRD_Agreements[Value])
RETURN
    IF(
        _Selection = "All Attributes",
        _Value,
        IF(_IsChg = "Changed", _Value, BLANK())
    )

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.