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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Create a DAX calendar table and bring data in

I have a table that looks like this:

 

DateCountryResult
01-JanJapan1
01-JanGermany2
01-JanUSA1.4
03-JanGermany5
03-JanUSA2.3
07-JanUSA3
08-JanJapan2
08-JanGermany2
08-JanUSA7.1

 

I want to create a new table whose first column is a calendar. The second and third columns would show the data of the original table. It would look like this:

 

DateCountryResult
01-JanJapan1
01-JanGermany2
01-JanUSA1.4
02-JanJapan0
02-JanGermany0
02-JanUSA0
03-JanJapan0
03-JanGermany5
03-JanUSA2.3
04-JanJapan0
04-JanGermany0
04-JanUSA0
05-JanJapan0
05-JanGermany0
05-JanUSA0
06-JanJapan0
06-JanGermany0
06-JanUSA0
07-JanJapan0
07-JanGermany0
07-JanUSA3
08-JanJapan2
08-JanGermany2
08-JanUSA7.1

 

Does anyone know how to do this?

 

I created a calendar table with the following code

NewTable = CALENDAR ( min('Table'[Date]), max('Table'[Date]) )

I added the result with a column

ResultColumn = 
CALCULATE (
    SUM ( 'Table'[Result] ),
    FILTER ('Table', 'Table'[Date] = NewTable[Date] )
)

But how do I add the column with the countries in there?

 

1 ACCEPTED SOLUTION

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

You can create a CALCULATED TABLE transforming your Table into Desired Format.

 

Basically it Adds the missing dates and cross joins the dates with all the Countries that existed before that date

Assuming your TableName is Table1.

Go to Modelling Tab>>New Table

 

Calculated Table =
VAR AllDates =
    CALENDAR ( MIN ( Table1[Date] ), MAX ( Table1[Date] ) )
VAR MissingDates =
    EXCEPT ( AllDates, VALUES ( Table1[Date] ) )
VAR temp =
    UNION ( ADDCOLUMNS ( MissingDates, "Country", BLANK (), "Result", 0 ), Table1 )
VAR temp1 =
    GENERATE (
        SUMMARIZE ( temp, [Date] ),
        CALCULATETABLE (
            FILTER ( SUMMARIZE ( temp, [Country] ), [Country] <> BLANK () ),
            FILTER ( temp, [Date] <= EARLIER ( [Date] ) )
        )
    )
RETURN
    ADDCOLUMNS (
        temp1,
        "Result",
        VAR result =
            LOOKUPVALUE ( Table1[Result], Table1[Country], [Country], Table1[Date], [Date] )
        RETURN
            IF ( ISBLANK ( result ), 0, result )
    )

@Anonymous

 

Please see the attached file as well

 

crtee.png

 

Anonymous
Not applicable

Thank you very much  🙂

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors