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
anvikuttu
Advocate I
Advocate I

DAX question

Hi Team,

I have trouble transforming Table A to the Output Calculated Table .  I wanted for every category and based on Min and Max dates, i want to generate consecutive dates between Min and Max for the Category field. Is it possible to do in DAX?

 

I could have done in M query, but then Table A is derived using DAX and moving back to power query and rebuilding there is a tough work.

 

Thank you

Table A:

AMinMax
Apple3/1/20233/5/2023
Orange2/1/20232/5/2023
Banana1/1/20231/5/2023

 

 

Output Calculated Table:

 

ADate
Apple3/1/2023
Apple3/2/2023
Apple3/3/2023
Apple3/4/2023
Apple3/5/2023
Orange2/1/2023
Orange2/2/2023
Orange2/3/2023
Orange2/4/2023
Orange2/5/2023
Banana1/1/2023
Banana1/1/2023
Banana1/3/2023
Banana1/4/2023
Banana1/5/2023
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @anvikuttu ,

 

using GENERATE and GENERATESERIES does the trick:

 

Table 2 = 
SELECTCOLUMNS(
    GENERATE(
        'Table'
        , var startValue = [Min]
        var endValue = [Max]
        return
        GENERATESERIES( startValue , endValue , 1 )
    )
    , "A" , [A]
    , "Date" , [Value]
)

 

A screenshot:
image.png

Hopefully, this provides what you are looking for.

Nevertheless, you must consider that DAX tables will not benefit from all compressions that are happening during data load/data refresh. If the table becomes large, you might encounter performance degradation when this table is used inside measures.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

6 REPLIES 6
FreemanZ
Super User
Super User

hi @anvikuttu 

you would need a date table to help, try create one like:

Dates = CALENDAR(MIN(TableA[Min]), MAX(TableA[Max]))

 

then write a calculated table like:

Table2 = 
GENERATE(
    VALUES(TableA[A]),
    VAR MinDate = CALCULATE(MIN(TableA[Min]))
    VAR MaxDate = CALCULATE(MAX(TableA[MAX]))
    RETURN
        CALCULATETABLE(
            VALUES(Dates[Date]),
            Dates[Date]>=MinDate,
            Dates[Date]<=MaxDate
        )
)

 

it worked like:

FreemanZ_0-1681279739823.png

TomMartens
Super User
Super User

Hey @anvikuttu ,

 

using GENERATE and GENERATESERIES does the trick:

 

Table 2 = 
SELECTCOLUMNS(
    GENERATE(
        'Table'
        , var startValue = [Min]
        var endValue = [Max]
        return
        GENERATESERIES( startValue , endValue , 1 )
    )
    , "A" , [A]
    , "Date" , [Value]
)

 

A screenshot:
image.png

Hopefully, this provides what you are looking for.

Nevertheless, you must consider that DAX tables will not benefit from all compressions that are happening during data load/data refresh. If the table becomes large, you might encounter performance degradation when this table is used inside measures.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thank you @TomMartens , I agree with your statement. In my case the data is not much.

tried to imitating  TomMartens' solution:

Table4 = 
GENERATE(
    VALUES(TableA[A]),
    VAR MinDate = CALCULATE(MIN(TableA[Min]))
    VAR MaxDate = CALCULATE(MAX(TableA[MAX]))
    RETURN
        GENERATESERIES(MinDate, MaxDate)
)

 

FreemanZ_0-1681281256245.png

Ritaf1983
Super User
Super User

Hi @anvikuttu 

You can achieve it with power query.
Please refer to attached link:
https://www.thepoweruser.com/2019/07/23/fill-dates-between-dates-with-power-bi-power-query/
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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

Thank you, however as mentioned in my msg i would like to do this in DAX

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.