Forum Discussion
Unable to Replace Column data in Matrix Using Switch
Hi abhifx ,
The problem is that MIS Form flows to a blank category in Database for MIS which of course doesn't have an equivalent in Trial. You can't expect Power BI to know which accounts in Trial should be aggregated for Total Sale.
This measure returns a value only if Line Item Desc is SALE, not Total Sale
Total Sales =
CALCULATE (
SUM ( Trial[Value in Lac] ),
'MIS Format'[Line Item Desc] = "SALE"
)
You can change this behaviour by using FILTER and wrapping 'MIS Format' in ALL. Your new measure would be:
Total Sales =
CALCULATE (
SUM ( Trial[Value in Lac] ),
FILTER ( ALL ( 'MIS Format' ), 'MIS Format'[Line Item Desc] = "SALE" )
)
This wil be tedious as you'll have to do that for all measures that return blank when they shouldn't. Alternatively, you can modify MIS Format so all category items that should be included in each Line Item Desc has its own line. For example, Total Int and Dept would have a line for Fin Charges and another one for Depreciation.
Dear danextian , Nailed it, it makes sense too. Thanks for going through my Power BI jungle and find out the issue.
As for the alternative suggestion, I still need to do all this manually only as this format is very rigid. But that is ok, Just a one time activity.
I have an additional query if you don't mind, I need to do two more things.
1) I want to divide each line by Total sales to get the percentage of sales as a separate column.
2) Subtract the current month from the previous month and also get the percentage variance.
- danextian2 years agoSuper User
The new Total Sales formula will give you the Total Sales value regardless of the filter applied to 'MIS Format' table so you can just use it as the denominator to get the % of sales. I would change the flow of relationship between 'MIS Format' and 'Database for MIS' to single direction though (from the former to latter) so the latter doesn't filter the former.
Getting the previous month's value would have been simple if you used a separate Dates table. Your month column doesn't mention which year they belong to but assuming they're from the same year, you can create a calculated table of months.
Months = VAR __NUMBER = GENERATESERIES ( 1, 12, 1 ) RETURN ADDCOLUMNS ( ADDCOLUMNS ( __NUMBER, "Date", DATE ( 2024, [Value], 1 ) ), "Month", FORMAT ( [Date], "mmm" ) )Then create a one to many relationshiop from Months[Month] to Trial[Month]. You can then use PREVIOUSMONTH to get the previous month's value. Sample formula:
PreviousMonth = CALCULATE ( [MyMeasure], PREVIOUSMONTH ( Months[Date] ) )The difference should be simply
= [MyMeasure] - [PreviousMonth]