Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi friends,
I want to create a calculated table using Summarize function which contains "Sales" and "Cost" measure.
Sales = CALCULATE(SUM(F_Sales[NetSales]),
TREATAS(VALUES('D_Table'[year_month]),F_Sales[yearmonth]),
TREATAS(VALUES('D_Table'[customer_no]),F_Sales[customer_no]))Cost = CALCULATE(SUM(F_Cost[Cost]),
TREATAS(VALUES('D_Table'[sup_code]), F_Cost[sup_code]),
TREATAS(VALUES('D_Table'[year_month]),F_Cost[year_month]),
TREATAS(VALUES('D_Table'[Product]),F_Cost[Product]))
Here is my calculated table:
Summarize_table =
SUMMARIZE(D_Table,
D_Table[rep_code],
D_Table[sup_code],
D_Table[year_month],
D_Table[product],
D_Table[Region],
"Sales",[Sales]
,"Cost",[Cost]
)
I compare the Sales measure and Cost measure in original table with Sales and Cost column in Summazie_table. The Sales gave me correct number. However, the cost made alot of difference.
I had no idea why I used exactly the same measures Sale and Cost in summarize_table. However, the result of cost is different. I want it exactly the same.
Could anyone please help me to solve it out?
Thank for your help.
Solved! Go to Solution.
I realized that my sale and cost measure using TREATAS must use the same granularity to make it work.
I realized that my sale and cost measure using TREATAS must use the same granularity to make it work.
Hello @tracytran91
I hope below code works for you.
Summarize_table =
VAR SalesTable =
SUMMARIZE(
D_TABLE,
'D_Table'[year_month],
'D_Table'[customer_no],
"Sales",[Sales]
)
VAR CostTable =
SUMMARIZE(
D_TABLE,
'D_Table'[sup_code],
'D_Table'[year_month],
'D_Table'[Product],
"Cost",[Cost]
)
RETURN
UNION(SalesTable,CostTable)
Thank You.
@Anonymous Thank for your reply.
I gave it a try and UNION function make the column Sales and Cost becomes a "sales" column. It is not my expectation.
Hello @tracytran91
Could you please share the pbix file after removing the sensitive information?
Thank You.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 32 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 65 | |
| 59 | |
| 31 | |
| 26 | |
| 25 |