Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
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
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!!!!
Solved! Go to Solution.
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 :
Fixed dax :
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
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.
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 :
Fixed dax :
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:
The slicer is the missing piece:
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
Scd tracking pbix :
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 Number | IsChanged | Attribute | Value | IsCurrent | Version |
| 00159957 | Changed | Current Price | 1100 | 1 | 1 |
| 00159957 | Changed | Current Price | 1300 | 0 | 1 |
| 00159957 | Changed | Current Price | 1300 | 1 | 2 |
| 00159957 | Changed | Current Price | 1430 | 1 | 2 |
| 00159957 | Changed | Effective Date | 46082 | 0 | 1 |
| 00159957 | Changed | Effective Date | 46082 | 1 | 1 |
| 00159957 | Changed | Effective Date | 46100 | 1 | 2 |
| 00161305 | Unchanged | Current Price | 745 | 1 | 1 |
| 00161305 | Unchanged | Effective Date | 46082 | 1 | 1 |
| 00162285 | Unchanged | Current Price | 57 | 1 | 1 |
| 00162285 | Unchanged | Current Price | 60 | 1 | 1 |
| 00162285 | Unchanged | Current Price | 175 | 1 | 1 |
| 00162285 | Unchanged | Effective Date | 46082 | 1 | 1 |
The dax measure is identical to yours.
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.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 45 | |
| 34 | |
| 27 | |
| 15 | |
| 15 |
| User | Count |
|---|---|
| 58 | |
| 56 | |
| 38 | |
| 21 | |
| 21 |