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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Dash7
Frequent Visitor

Calendar table problem (blanks)

I have a table that contains columns: TASKID, created_on, Implemented_on.  As you probably know, column Implemented_on can maintain empty cells.
anyway I want to create simple visual, tasks created vs tasks implemented in period of time.

I created calendar table, but problem is it does not shows even date on the x line.

Dash7_0-1705933011927.png

 


I tried to create few calendar tables using below codes:

_Calendar = 
ADDCOLUMNS(
    FILTER(
    CALENDAR(
        MIN('table'[Created]),
        MAX('table'[Implemented On])
    ),
    NOT(ISBLANK(MIN('table'[Implemented On])))
)
      
    ,
    "Year", YEAR([Date]),
    "Month", CONVERT(MONTH([Date]), INTEGER),
    "Month name", FORMAT([Date], "mmmm"),
    "Month short", FORMAT([Date], "mmm"),
    "Weeknumber", WEEKNUM([Date], 21),
    "Quarter", QUARTER([Date]),
    "Day", DAY([Date]),
    "Day name", FORMAT([Date], "dddd"))
   

or 

Calendar = 
ADDCOLUMNS(
ADDCOLUMNS(
CALENDAR(MIN('table'[created]),
    MAX('table'[implemented on])),
"Year",YEAR([Date]),
"Month",CONVERT(MONTH([Date]),INTEGER),
"Month name",FORMAT([Date],"mmmm"),
"Month short", FORMAT([Date],"mmm"),
"Weeknumber",WEEKNUM([Date],21),
"Quarter",QUARTER([Date]),
"Day",DAY([Date]),
"Day name",FORMAT([Date],"dddd")),
"Year Month", [Year]&IF([Month]<10,"0"&[Month],[Month]))

or even 

_CALENDAR_TABLE = 
VAR __startDate = DATE ( 2021, 1, 1 ) 
VAR __endDate = DATE ( YEAR ( TODAY() ), 12, 31 ) 
VAR __dates = CALENDAR ( __startDate, __endDate )
RETURN
ADDCOLUMNS (
    __dates,
    "Year",             YEAR ( [Date] ),
    "Month Number",     MONTH ( [Date] ),
    "Month Name",       FORMAT ( [Date], "MMMM" ), 
    "Month",            FORMAT( [Date], "MMM, YYYY" ), 
    "Month Sort",       FORMAT( [Date], "YYYY-MM" ),
    "Quarter",          "Q" & FORMAT( [Date], "Q, YYYY" ),
    "Quarter Sort",     FORMAT ( [Date], "YYYY-Q" )
)

All tables i tried to connect with the main table with created/implemented on columns or both at once
Could anyone help me how to solve that? (important thing, I do not want to duplicate rows)

1 ACCEPTED SOLUTION
v-jingzhan-msft
Community Support
Community Support

Hi @Dash7 

 

This blank issue is not caused by the calendar table. As column Implemented_on can maintain empty cells, if you add measures/columns related to Implemented_on dates to the chart, the empty date values will be aggregated to the "Blank" column as you showed in the picture. 

 

As a workaround, you need to filter out those empty date values in measures. For example, 

Implemented No. = CALCULATE(COUNT('Table'[TaskID]),NOT(ISBLANK('Table'[Implemented_on])),USERELATIONSHIP(_CALENDAR_TABLE[Date],'Table'[Implemented_on]))

Note that I use USERELATIONSHIP function in this measure because I created the relationship between these two columns as inactive. 

vjingzhanmsft_0-1705981176400.png

 

I created a demo pbix with the last calendar table code you offered. You can download it to see the details. 

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

View solution in original post

(Virus scan in progress ...)
3 REPLIES 3
Dash7
Frequent Visitor

@v-jingzhan-msft  thank you very much for help. It works perfectly! 

v-jingzhan-msft
Community Support
Community Support

Hi @Dash7 

 

This blank issue is not caused by the calendar table. As column Implemented_on can maintain empty cells, if you add measures/columns related to Implemented_on dates to the chart, the empty date values will be aggregated to the "Blank" column as you showed in the picture. 

 

As a workaround, you need to filter out those empty date values in measures. For example, 

Implemented No. = CALCULATE(COUNT('Table'[TaskID]),NOT(ISBLANK('Table'[Implemented_on])),USERELATIONSHIP(_CALENDAR_TABLE[Date],'Table'[Implemented_on]))

Note that I use USERELATIONSHIP function in this measure because I created the relationship between these two columns as inactive. 

vjingzhanmsft_0-1705981176400.png

 

I created a demo pbix with the last calendar table code you offered. You can download it to see the details. 

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

 

(Virus scan in progress ...)
Ritaf1983
Super User
Super User

Hi @Dash7 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements