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
Haripinnoju
Frequent Visitor

Dax query to create a calculated column date

Hi,

I have year and quarter columns, I need to create a calculated column from which I can get the date through this year and quarter columns, i.e., the date may be any either 1st of any month or in between the months.

Eg., Year 2022 quarter Q2 then date can be  04/05/2022 or 01/05/2022 etc.

 

I cannot use custom column.

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

Hi @Haripinnoju ,

 

Cannot use a calculated column to insert rows, the rows in the calculated column are the same as the rows in the table.

vcgaomsft_0-1686712838806.png

 

Consider creating a new table.

 

Table 2 = 
VAR _min_year =
    MIN ( 'Table'[Year] )
VAR _min_year_quarter =
    INT (
        RIGHT ( CALCULATE ( MIN ( 'Table'[Quarter] ), 'Table'[Year] = _min_year ), 1 )
    )
VAR _max_year =
    MIN ( 'Table'[Year] )
VAR _max_year_quarter =
    INT (
        RIGHT ( CALCULATE ( MIN ( 'Table'[Quarter] ), 'Table'[Year] = _min_year ), 1 )
    )
VAR _table =
    CALENDAR (
        DATE ( _min_year, 3 * _min_year_quarter - 2, 1 ),
        DATE ( _max_year, _max_year_quarter * 3, 1 )
    )
RETURN
    _table

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @Haripinnoju ,

 

Cannot use a calculated column to insert rows, the rows in the calculated column are the same as the rows in the table.

vcgaomsft_0-1686712838806.png

 

Consider creating a new table.

 

Table 2 = 
VAR _min_year =
    MIN ( 'Table'[Year] )
VAR _min_year_quarter =
    INT (
        RIGHT ( CALCULATE ( MIN ( 'Table'[Quarter] ), 'Table'[Year] = _min_year ), 1 )
    )
VAR _max_year =
    MIN ( 'Table'[Year] )
VAR _max_year_quarter =
    INT (
        RIGHT ( CALCULATE ( MIN ( 'Table'[Quarter] ), 'Table'[Year] = _min_year ), 1 )
    )
VAR _table =
    CALENDAR (
        DATE ( _min_year, 3 * _min_year_quarter - 2, 1 ),
        DATE ( _max_year, _max_year_quarter * 3, 1 )
    )
RETURN
    _table

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

some_bih
Super User
Super User

Hi @Haripinnoju it seems you need to create Date table in Power BI. Check link. I hope this help https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/ 





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

Proud to be a Super User!






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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.