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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Gandhary80
Frequent Visitor

How to have the months in contingency table not counted together

Hello,

 

I have follow data in excel:

Gandhary80_0-1728282003752.png

 

As you can see, there are most of data from year 2023, but 1 line ifrom 3rd of January 2024. When I create the contingency table visual, I have this result:

Gandhary80_1-1728282343564.png

 

How to make the visual showing the data of Janury 2024 next to December (Prosinec) and not to count them together with January (Leden) 2023?

 

Thank you very much for your help.

 

 

1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @Gandhary80  See the image below:

shafiz_p_0-1728284460740.png

 

You can also sort month name by using month number column. See image below:

shafiz_p_1-1728284558210.png

 

 

By using year and month name in column in matrix visual you will get your desired result.

 

Hope this helps!!

If this solved your problem, please accept it as a solution!!

 

Best Regards,

Shahariar Hafiz

View solution in original post

3 REPLIES 3
shafiz_p
Super User
Super User

Hi @Gandhary80  See the image below:

shafiz_p_0-1728284460740.png

 

You can also sort month name by using month number column. See image below:

shafiz_p_1-1728284558210.png

 

 

By using year and month name in column in matrix visual you will get your desired result.

 

Hope this helps!!

If this solved your problem, please accept it as a solution!!

 

Best Regards,

Shahariar Hafiz

danextian
Super User
Super User

Hi @Gandhary80 

 

Add a year column to you data to break down your visual by year. However, it is a best practice to use a separate dates/calendar table and relate that to your fact table, which normally has additional column for year, month, quarter, week, etc. Below is a sample M query that generates  rows of dates from Jan 1, 2020 up to today's date + 28 more days.

let
    Date_Today = Date.AddDays(Date.From(DateTime.From(DateTimeZone.SwitchZone(DateTimeZone.FixedUtcNow(),8))),1),
    DateToday = Date.From(DateTime.From(DateTimeZone.RemoveZone(DateTimeZone.UtcNow()) + #duration(0,8,0,0))),
    Dates = let 
StartDate = #date(2020, 1, 1 ),
Count = Number.From(Date.AddDays(DateToday, 28)) - Number.From(StartDate),
Dates = List.Dates(StartDate, Count, #duration(1,0,0,0))

in Table.FromColumns({Dates}, {"Date"}),
    #"Inserted Month Name" = Table.AddColumn(Dates, "Month Short", each Text.Start(Date.MonthName([Date]), 3), type text),
    #"Inserted Month Name1" = Table.AddColumn(#"Inserted Month Name", "Month Long", each Date.MonthName([Date]), type text),
    #"Inserted Month" = Table.AddColumn(#"Inserted Month Name1", "Month Number", each Date.Month([Date]), Int64.Type),
    #"Inserted Year" = Table.AddColumn(#"Inserted Month", "Calendar Year", each Date.Year([Date]), Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Inserted Year", "FY Month Sort", each if [Month Number] >=10 then [Month Number] - 9 else [Month Number] + 3, Int64.Type),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "FY", each "FY"  &
Text.End(Text.From( if [Month Number] >=10 then [Calendar Year] + 1 else [Calendar Year]),2), type text),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Month & Year", each Date.ToText([Date], "MMM-yy"), type text),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Period", each Date.ToText([Date], "yyyyMM"), type text),
    #"Added Custom4" = Table.AddColumn(#"Added Custom3", "IsFutureDate", each [Date] >=DateToday, type logical),
    #"Inserted Day" = Table.AddColumn(#"Added Custom4", "Day of Month", each Date.Day([Date]), Int64.Type),
    #"Inserted Day Name" = Table.AddColumn(#"Inserted Day", "Day Name", each Text.Start(Date.DayOfWeekName([Date]), 3), type text),
    #"Inserted Day of Week" = Table.AddColumn(#"Inserted Day Name", "Day of Week", each Date.DayOfWeek([Date], Day.Monday), Int64.Type),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Day of Week",{{"Date", type date}}),
    #"Week Starting Monday" = Table.AddColumn(#"Changed Type", "Week Starting Monday", each Date.StartOfWeek([Date], Day.Monday), type date),
    #"Week Starting Sunday" = Table.AddColumn(#"Week Starting Monday", "Week Starting Sunday", each Date.StartOfWeek([Date], Day.Sunday), type date),
    #"Week Ending Thursday" = Table.AddColumn(#"Week Starting Sunday", "Week Ending Thursday", each Date.EndOfWeek([Date], Day.Friday), type date),
    #"Week Ending Friday" = Table.AddColumn(#"Week Ending Thursday", "Week Ending Friday", each Date.EndOfWeek([Date], Day.Saturday), type date),
    #"Week Ending Saturday" = Table.AddColumn(#"Week Ending Friday", "Week Ending Saturday", each Date.EndOfWeek([Date], Day.Friday), type date),
    #"Week Ending Sunday" = Table.AddColumn(#"Week Ending Saturday", "Week Ending Sunday", each Date.EndOfWeek([Date], Day.Monday), type date)
in
    #"Week Ending Sunday"

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
dharmendars007
Super User
Super User

Hello @Gandhary80 , 

 

If you want the 2024 to display seprately then you need to include the year in your table visual , because currently there is no year which can filter values in your table.

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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