Forum Discussion
How to create a summary table
- Anonymous1 year ago
Hi POSPOS ,
Please create a new table :
And 3 measures:
Sales 1 = VAR __curr_dept = MAX('Table'[Dept]) VAR __curr_div = MAX('Table'[Div]) VAR __result = IF( HASONEVALUE('Table'[Dept]), CALCULATE(SUM('Master'[Sales]),'Master'[Dept]=__curr_dept&&'Master'[Div]=__curr_div), SUM('Master'[Sales])) RETURN __resultSales 2 = VAR __curr_dept = MAX('Table'[Dept]) VAR __curr_div = MAX('Table'[Div]) VAR __sales = IF(HASONEVALUE('Table'[Dept]), CALCULATE(SUM('Source 1'[Sales]),'Source 1'[Dept]=__curr_dept, 'Source 1'[Div]=__curr_div), SUM('Source 1'[Sales])) VAR __result = __sales - [Sales 1] RETURN __resultSales 3 = VAR __curr_dept = MAX('Table'[Dept]) VAR __curr_div = MAX('Table'[Div]) VAR __sales = IF( HASONEVALUE('Table'[Dept]), CALCULATE(SUM('Source 2'[Sales]),'Source 2'[Dept]=__curr_dept, 'Source 2'[Div]=__curr_div), SUM('Source 2'[Sales])) VAR __result = __sales - [Sales 1] RETURN __resultBest Regards,
Gao
Community Support TeamIf 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
Anonymous - When I use the above measures in another calcuated column, then I get circular dependency error.
eg: column = if( sales 2 <>0, "Y","N")
Can you please suggest on to fix this.
Hi POSPOS ,
These two blogs explain the cause of the error and how to avoid it.
Understanding circular dependencies in DAX - SQLBI
Avoiding circular dependency errors in DAX - SQLBI
You can also consider going to build the previous table in Powerquery, see the steps in Query1.
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