Forum Discussion

waleed111's avatar
waleed111
Helper V
5 years ago

Relationship and filter

When i try to use date column as axis in my chart it not work and gave me blank for all values, this is the chart:

 

and this is the axis and values:

 

and this is the model and relationships:

 

so what is the problem and what is the solution?

11 Replies

  • waleed111 , Power BI default is right join (1 -M side) unless you handled blank() or add +0 which will make it left join.

     

    Seem like values are missing less in date table.

    • waleed111's avatar
      waleed111
      Helper V

      what the relation between joining and our question? and how to solve the problem and make the date work.

  • Anonymous's avatar
    Anonymous
    Not applicable

    hi waleed111 - can you validate if all the dates in your FACT table are available in the Date table?

    Power BI will not be able to identify Quarters for dates that are not available in the data table

     

    Please mark the post as a solution and provide a 👍 if my comment helped with solving your issue. Thanks!

    • waleed111's avatar
      waleed111
      Helper V

      I make date column using CALENDARAUTO then i connect it with another date column in another table but the relation didn't work.

       

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    waleed111 

    If you want to remove the blank values, select the date field in the filter pane and uncheck "Blank"

  • Hi waleed111 

     

    2nd snapshot that you've shared there you can see Date --> year --> Quarter--> Month --> Day, click on the down arrow next to Date and select date instead of date hierachy.

     

    Please let me know if it still doesn't solve your issue. Please delete PII data and share your pbix file so I can review that.

     

    Also use this as blank query to get a dynamic date table.

     

    let fnDateTable = (StartDate as date, EndDate as date, FYStartMonth as number) as table =>
    let
    DayCount = Duration.Days(Duration.From(EndDate - StartDate)),
    Source = List.Dates(StartDate,DayCount,#duration(1,0,0,0)),
    TableFromList = Table.FromList(Source, Splitter.SplitByNothing()),
    ChangedType = Table.TransformColumnTypes(TableFromList,{{"Column1", type date}}),
    RenamedColumns = Table.RenameColumns(ChangedType,{{"Column1", "Date"}}),
    InsertYear = Table.AddColumn(RenamedColumns, "Year", each Date.Year([Date]),type text),
    InsertYearNumber = Table.AddColumn(RenamedColumns, "YearNumber", each Date.Year([Date])),
    InsertQuarter = Table.AddColumn(InsertYear, "QuarterOfYear", each Date.QuarterOfYear([Date])),
    InsertMonth = Table.AddColumn(InsertQuarter, "MonthOfYear", each Date.Month([Date]), type text),
    InsertDay = Table.AddColumn(InsertMonth, "DayOfMonth", each Date.Day([Date])),
    InsertDayInt = Table.AddColumn(InsertDay, "DateInt", each [Year] * 10000 + [MonthOfYear] * 100 + [DayOfMonth]),
    InsertMonthName = Table.AddColumn(InsertDayInt, "MonthName", each Date.ToText([Date], "MMMM"), type text),
    InsertCalendarMonth = Table.AddColumn(InsertMonthName, "MonthInCalendar", each (try(Text.Range([MonthName],0,3)) otherwise [MonthName]) & " " & Number.ToText([Year])),
    InsertCalendarQtr = Table.AddColumn(InsertCalendarMonth, "QuarterInCalendar", each "Q" & Number.ToText([QuarterOfYear]) & " " & Number.ToText([Year])),
    InsertDayWeek = Table.AddColumn(InsertCalendarQtr, "DayInWeek", each Date.DayOfWeek([Date])),
    InsertDayName = Table.AddColumn(InsertDayWeek, "DayOfWeekName", each Date.ToText([Date], "dddd"), type text),
    InsertWeekEnding = Table.AddColumn(InsertDayName, "WeekEnding", each Date.EndOfWeek([Date]), type date),
    InsertWeekNumber= Table.AddColumn(InsertWeekEnding, "Week Number", each Date.WeekOfYear([Date])),
    InsertMonthnYear = Table.AddColumn(InsertWeekNumber,"MonthnYear", each [Year] * 10000 + [MonthOfYear] * 100),
    InsertQuarternYear = Table.AddColumn(InsertMonthnYear,"QuarternYear", each [Year] * 10000 + [QuarterOfYear] * 100),
    ChangedType1 = Table.TransformColumnTypes(InsertQuarternYear,{{"QuarternYear", Int64.Type},{"Week Number", Int64.Type},{"Year", type text},{"MonthnYear", Int64.Type}, {"DateInt", Int64.Type}, {"DayOfMonth", Int64.Type}, {"MonthOfYear", Int64.Type}, {"QuarterOfYear", Int64.Type}, {"MonthInCalendar", type text}, {"QuarterInCalendar", type text}, {"DayInWeek", Int64.Type}}),
    InsertShortYear = Table.AddColumn(ChangedType1, "ShortYear", each Text.End(Text.From([Year]), 2), type text),
    AddFY = Table.AddColumn(InsertShortYear, "FY", each "FY"&(if [MonthOfYear]>=FYStartMonth then Text.From(Number.From([ShortYear])+1) else [ShortYear]))
    in
    AddFY
    in
    fnDateTable

     

     

     

     

     

    Thanks,
    Ankit Kukreja

    Linkedin 

    • waleed111's avatar
      waleed111
      Helper V

      Thank you AnkitKukreja, my problem solved, but now my date columns loss thire hirarachy:

      i need them to be like this date with hirarachy:

       but they come like this:

       then how can i gave them hirarachy againe. 


      • AnkitKukreja's avatar
        AnkitKukreja
        Super User

         

        waleed111 

         

        It's very difficult to ans anything without actually seeing the model.

        But if you've a date column and if you'll drag that filed there is a arrow next to that where you can select it as date hierarchy (ss below) or use my query for your date table then you can pull any date field you would like to display.

         

         

        Thanks,
        Ankit Kukreja

        LinkedIn 

         

         

  • v-xicai's avatar
    v-xicai
    Community Support

    Hi waleed111 ,

     

    The reason why the Blank Values appears may be it hasn’t matched with all the row values in these tables. You may change the Cross filter direction of relationships among the these tables above from Single to Both , which will take these tables treated as a single table. Then when you make some changes or interact in someone table, the other table objects will return corresponding matched result.  See more:Create and manage relationships in Power BI Desktop .

     

    Best Regards,

    Amy 

     

    Community Support Team _ Amy

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

  • v-xicai's avatar
    v-xicai
    Community Support

    Hi  waleed111  ,

     

    Do the suggestions from engineers make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

     

    Best regards

    Amy