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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Querying to show data based on certain date columns

I have a date table with many columns for different areas surrounding date and times. I have a quarter column to show if each row belongs in Q1, 2, 3, or 4. I have a Reporting Month, Reporting Quarter, and Reporting Year column that tells me if the current row is the current reporting month, quarter, and year. These 3 columns are type logical in Power Query. 

I have a certain ask from one of my clients for a report that if the current reporting quarter is Q1. Then show Q4 of last year and Q1 of this year's data so they can see a trend leading into the new year. If the current reporting quarter is not Q1 ie Q2, 3, or 4, then only show this current year's data.

I have tried multiple work arounds in Power Query to create a column to facilitate this so I can use this column as a page level filter.

The main issue is that I cannot say when quarter = 1 and quarter = 4. It has to be 1 or 4 but to show Q4, it is dependent on Q1. If anyone has any suggestions on Power Query code for this would be greatly appreciated, thanks. 

5 REPLIES 5
Anonymous
Not applicable

DateYearQuarterCompleted MonthCompleted YearCompleted QuarterReporting MonthReporting QuarterReporting Year
28/12/20232023Q4TRUETRUETRUEFALSEFALSEFALSE
29/12/20232023Q4TRUETRUETRUEFALSEFALSEFALSE
30/12/20232023Q4TRUETRUETRUEFALSEFALSEFALSE
31/12/20232023Q4TRUETRUETRUEFALSEFALSEFALSE
1/1/20242024Q1FALSEFALSEFALSETRUETRUETRUE
2/1/20242024Q1FALSEFALSEFALSETRUETRUETRUE
3/1/20242024Q1FALSEFALSEFALSETRUETRUETRUE

The table has a lot more columns than this, but these are the 9 columns that would be used for this logic I am trying to build.

Essentially I want if the reporting quarter = true and quarter = Q1 then show Q1 and show Q4 where Year = Reporting Year - 1 (I have seperate logic working for this as an intermediate step rather than as a column itself). Else show data only where Reporting Year = True and Completed Month = True.

 

Data from this table ranges back to 2021

 

I hope this clarifies the data structure

@Anonymous OK, so then this table is linked to a fact table that has values of something in it? Or are those values in that table as well? Makes a difference in terms of the actual solution.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This table links to multiple fact tables with a date column in each table. The table has a relationship from the Date column in the table above to all of the other datasets.

Anonymous
Not applicable

@Greg_Deckler see above

Greg_Deckler
Super User
Super User

@Anonymous Perhaps just create a Q4 DAX measure that only displays if the quarter is Q1 or Q4. Also have your other measure for display Q1, Q2 and Q3 only. Then put both in whatever visual. 

 

Otherwise, sample data would help tremendously. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors