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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
tecumseh
Resolver I
Resolver I

Return Select Columns As Last Step In Calculated Table

Hi,

In my Calculated Table, I return all dates for Sales and calculate the quarter for each date.
Now I want to return just the Customer id and Quarter

However DAX is telling me it cannot find the intermediary table I used to calculate the quarter for each date.

How can I get just the customer id and the quarter in my final calc table?

Thanks

Table_x = 
VAR T10 =
FILTER(
Sales,
Sales[Channel] = "Education" &&
Sales[Customer ID] <> "Adjustments" &&
Sales[Net Revenue] > 0
)
VAR T20 =
SUMMARIZECOLUMNS(
Sales[Customer ID],
Sales[Date],
T10
)
VAR T30 =
ADDCOLUMNS(
T20,
"Quarter",
DATE(YEAR(Sales[Date]),ROUNDUP( DIVIDE( MONTH( Sales[Date] ),3 ),0 ) *3 -2, 1)
)
VAR T40 =
SELECTCOLUMNS(
T30,
"Customer ID", T30[Customer ID],
"Quarter", T30[Quarter]
)


RETURN
T40





1 ACCEPTED SOLUTION
foodd
Super User
Super User

This was written on a phone and is untested.  You may need to change the DAX as necessary.  This is related to the context transition, which can cause intermediate tables to be unavailable for use in later steps of the calculation. To achieve the desired result, you can simplify the DAX code and perform the date calculations directly within the SELECTCOLUMNS function. Try this

 

Table_x =
VAR T10 =
FILTER(
Sales,
Sales[Channel] = "Education" &&
Sales[Customer ID] <> "Adjustments" &&
Sales[Net Revenue] > 0
)
VAR T40 =
SELECTCOLUMNS(
T10,
"Customer ID", Sales[Customer ID],
"Quarter", DATE(YEAR(Sales[Date]), ROUNDUP(DIVIDE(MONTH(Sales[Date]), 3), 0) * 3 - 2, 1)
)
RETURN
T40

View solution in original post

1 REPLY 1
foodd
Super User
Super User

This was written on a phone and is untested.  You may need to change the DAX as necessary.  This is related to the context transition, which can cause intermediate tables to be unavailable for use in later steps of the calculation. To achieve the desired result, you can simplify the DAX code and perform the date calculations directly within the SELECTCOLUMNS function. Try this

 

Table_x =
VAR T10 =
FILTER(
Sales,
Sales[Channel] = "Education" &&
Sales[Customer ID] <> "Adjustments" &&
Sales[Net Revenue] > 0
)
VAR T40 =
SELECTCOLUMNS(
T10,
"Customer ID", Sales[Customer ID],
"Quarter", DATE(YEAR(Sales[Date]), ROUNDUP(DIVIDE(MONTH(Sales[Date]), 3), 0) * 3 - 2, 1)
)
RETURN
T40

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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