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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
grasa
Regular Visitor

Problem with Month-Year view

Dear all,

I have a column formatted as date (called "_Vorauss. Baubeginn"). It includes data with day, month and year.

Now I would like to get the data aggregated to just month/year to use that in a filter.

 

grasa_0-1725610437346.png

 

My idea was to extract the year and mont (by using the MONTH/YEAR formular) and use the DATE forumla by entering Year Baubeginn, Month Baubeginn and 1 (as day).

Unfortunately I´m not able to select the year or month I extracted previously.

 

grasa_1-1725611092939.png

 

 

Do you have an idea how I can solve this? Or am I thinking to complicated and there is a much easier way to get the month/year values.

 

Thank you very much in advance for your help.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @grasa 

 

Thanks for the reply from 123abc .

 

Do you need to display the data of the month selected in the filter in the table visualization? If I understand correctly, please refer to the following test, in my test, I use DiectQuery mode to connect two tables, one of the tables as a filter, if the data structure I use is different from yours, please feel free to correct me.

 

Table_1

vxuxinyimsft_0-1725850971414.png

 

filter_table

vxuxinyimsft_1-1725851030086.png

 

vxuxinyimsft_2-1725851058210.png

 

Then I created a measure as follows.

Measure = IF(SELECTEDVALUE(filter_table[Date]) = BLANK(), 1, IF(YEAR(MAX([Date])) = YEAR(SELECTEDVALUE(filter_table[Date])) && MONTH(MAX([Date])) = MONTH(SELECTEDVALUE(filter_table[Date])), 1, 0))

 

Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_5-1725851351315.png

 

Put the Date field of filter_table into Filter

 

Output:

vxuxinyimsft_4-1725851296384.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

grasa
Regular Visitor

Thanks to all for your help, I think I found a solution that works for me: I created a new calendar table which includes all the dates from my "_vorauss.Baubeginn" column. Within this table I created a new mmmm-yyyy column.

grasa_1-1727083191800.png

 

grasa_2-1727083243015.png

 

 

 

View solution in original post

8 REPLIES 8
grasa
Regular Visitor

Sorry for the late reply. I don´t need the data in the filter section but as a visual like this, but only showing months and years, without days:

 

grasa_0-1727079465119.png

 

Unfortunately the solution from @123abc about handling blanks wasn´t working. If I create a new column there occurs an error:

grasa_1-1727079745821.png

 

if I try to create a measure, I´m not able to select the "_Vorauss. Baubeginn" column... Maybe I have to live with the day...🙈

grasa
Regular Visitor

Thanks to all for your help, I think I found a solution that works for me: I created a new calendar table which includes all the dates from my "_vorauss.Baubeginn" column. Within this table I created a new mmmm-yyyy column.

grasa_1-1727083191800.png

 

grasa_2-1727083243015.png

 

 

 

Anonymous
Not applicable

Hi @grasa 

 

Thanks for the reply from 123abc .

 

Do you need to display the data of the month selected in the filter in the table visualization? If I understand correctly, please refer to the following test, in my test, I use DiectQuery mode to connect two tables, one of the tables as a filter, if the data structure I use is different from yours, please feel free to correct me.

 

Table_1

vxuxinyimsft_0-1725850971414.png

 

filter_table

vxuxinyimsft_1-1725851030086.png

 

vxuxinyimsft_2-1725851058210.png

 

Then I created a measure as follows.

Measure = IF(SELECTEDVALUE(filter_table[Date]) = BLANK(), 1, IF(YEAR(MAX([Date])) = YEAR(SELECTEDVALUE(filter_table[Date])) && MONTH(MAX([Date])) = MONTH(SELECTEDVALUE(filter_table[Date])), 1, 0))

 

Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_5-1725851351315.png

 

Put the Date field of filter_table into Filter

 

Output:

vxuxinyimsft_4-1725851296384.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

123abc
Community Champion
Community Champion

To aggregate your date column (called "_Vorauss. Baubeginn") by month and year for use as a filter in Power BI, you can follow these steps:

 

Create a calculated column that extracts the month and year from your date column "_Vorauss. Baubeginn".

You can use the following DAX formula to create a new column that shows the first day of the month for each date in your original column:

 

MonthYearColumn = DATE(YEAR([_Vorauss. Baubeginn]), MONTH([_Vorauss. Baubeginn]), 1)

 

  1. This will give you a date formatted as the first day of each month, which can be used to group and filter your data by month and year.

  2. Use the calculated column in a slicer or visual:

    Now that you have a column with the year and month, you can use it in a slicer to filter your data by month and year.

Alternative Approach (Using FORMAT):

If you don't need the exact date and only want a textual representation (e.g., "January 2024"), you can create a calculated column with a formatted string for month and year:

 

MonthYearText = FORMAT([_Vorauss. Baubeginn], "MMM YYYY")

 

MonthYearText = FORMAT([_Vorauss. Baubeginn], "MMM YYYY")

 

If you have any issue please feel free and contact with me.

@123abc thank you very much for your fast reply! I tried your first option but unfortunately it says that there weren´t found any data for that visual.

 

grasa_0-1725613001546.png

 

And I´m not able to try the second option, there occures an error which says that the function "FORMAT" is not allowed in DAX expressions for calculated columns in DirectQuery models 😞...

 

123abc
Community Champion
Community Champion

Thank you for your feedback! Since you're using DirectQuery, it limits some of the DAX functions like FORMAT, which causes the error you're seeing. Let's tackle this issue by adjusting our approach to work within the DirectQuery constraints.

 

Option 1: Workaround for Date Aggregation in DirectQuery

We can avoid using functions that are not supported in DirectQuery, like FORMAT, and rely solely on DAX functions that are allowed.

Step 1: Extract Year and Month

Instead of using the FORMAT function, let's directly extract the year and month in numeric form and combine them.

Create two calculated columns for Year and Month:

 

YearColumn = YEAR([_Vorauss. Baubeginn])
MonthColumn = MONTH([_Vorauss. Baubeginn])

 

Step 2: Combine Year and Month

Since DirectQuery doesn’t allow FORMAT, we’ll combine the year and month into a new column as text without FORMAT:

 

YearMonth = [YearColumn] * 100 + [MonthColumn]

 

This will create a column like 202401 for January 2024, which you can use as a slicer or in visuals.

Alternatively, if you want a date for the first of the month, this formula will work:

 

FirstOfMonth = DATE(YEAR([_Vorauss. Baubeginn]), MONTH([_Vorauss. Baubeginn]), 1)

 

Step 3: Use the New Column in Visuals

Now, use either the YearMonth or FirstOfMonth column in your visuals or slicers to filter by month and year.

Option 2: Modify Your Data Model (If Possible)

If you have control over your data source, you could consider switching to Import Mode rather than DirectQuery for more flexibility. Import Mode allows you to use functions like FORMAT and gives you more control over transformations.

Let me know if you encounter any further issues, and we’ll continue to refine the solution!

@123abc Thanks again for your fast help 😊.

Unfortunately this is also not working, it says that the data for this visual isn´t found. Do you think this is because there are also blanks in the "_Vorauss. Baubeginn" column?

 

grasa_0-1725616282690.png

I could switch to Import Mode and I also tried that earlier but then there occures an error saying it is not possible because there are some blanks in some tables. 

123abc
Community Champion
Community Champion

Yes, the issue you're facing could indeed be caused by the blanks in the "_Vorauss. Baubeginn" column. When there are null values, calculations like DATE(), YEAR(), and MONTH() might fail or return unexpected results.

 

You can modify your DAX formulas to handle blanks by using the IF and ISBLANK functions, ensuring that calculations only happen when there is valid data.

For example, you can wrap the DATE function to avoid calculations when the value is blank:

 

FirstOfMonth = IF(
ISBLANK([_Vorauss. Baubeginn]),
BLANK(),
DATE(YEAR([_Vorauss. Baubeginn]), MONTH([_Vorauss. Baubeginn]), 1)
)

 

This will return a blank value if "_Vorauss. Baubeginn" is blank, avoiding errors.

 

Replace Blanks with a Default Date

 

FirstOfMonth = IF(
ISBLANK([_Vorauss. Baubeginn]),
DATE(1900, 1, 1), // You can choose any default date here
DATE(YEAR([_Vorauss. Baubeginn]), MONTH([_Vorauss. Baubeginn]), 1)
)

 

This replaces the blank entries with a default date (e.g., January 1, 1900), ensuring no null values are present.

 

If the switch to Import Mode fails due to blanks in other tables, handling these blanks similarly—by either removing them or filling them with default values—can help resolve the issue.

Steps to Handle Blanks Before Import Mode:

  1. Check All Tables for Blanks: Identify columns with blank values.
  2. Fill Blanks: Either use DAX or Power Query transformations to fill those blanks with a default value.
  3. Switch to Import Mode: After handling blanks, try switching again.

Let me know how this works for you!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.