Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Select a column value based on filter

Hi all,  I have data as follows:   Date                   MonthnYear 1/7/2020            July 2020 2/7/2020            July 2020 3/7/2020            July 2020 4/7/2020            July 2020 ...
  • AllisonKennedy's avatar
    5 years ago
    Anonymous

    As Anonymous has already mentioned, you can fix this by formatting your date measure. Just to explain why using max all to your Monthnyear column doesn't work is because this sorting them alphabetically rather than chronologically. Monthnyear is just a text data type, so will be sorted alphabetically.

    Two ways to format:
    1) if you want something specific in a card visual as requested, use the DAX FORMAT() function:

    Max Month Year = FORMAT([Max Date All], "MMM YYYY")

    NOTE: this method will convert your measure to a text data type. Shouldn't be a problem for measures, but for custom columns this means it will sort alphabetically as explained above.

    2) Format the measure in the Model view using custom formatting https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-custom-format-strings

    NOTE: This method just applies formatting on top of the existing measure without coverting the data type.