"powerbi"
6 TopicsHow to calculate subtotal correctly with hierarchies
Hi I am struggling with the following problem. I have a fact table in which I already receive calculated values per category and subcategory in one table. The totals per category and subcategory do not and should not be equal. Let's assume we have category A, which is divided into 3 subcategories: AA, AB, AC. The entire category A is supposed to have a subtotal of 370, and the subcategory AA is 50, AB 100 and AC 200. The sum of the subcategories is 350, but I would not like to see 350, but 370. I already receive the calculated data from the backend layer: Since I have one column with values that simultaneously contains the sum of the entire category and the subcategory values, the whole thing is duplicated in the sums. How can I approach this differently? This is an example, the real case has a category and a tree with 8 levels of subcategories, so it is very important for me that the solution is calculated correctly.1.1KViews0likes5CommentsI need to supress the rows where the column sub-total has no value.
The show items with No data works, if I have not formatted the Amounts in my columns, but once I format it using DAX, this option doesn't work anymore. This one is w/o formatting the amount column This one is after formatting the Amount Columns(Month-Year) My DAX for Visual 2 - What can I add here to suppress rows which have no data in the month columns! Actuals = VAR _selectedHeader = SELECTEDVALUE ('a360_finance fin_PnL_Template2'[Level_1]) VAR _Actuals = FORMAT([Actual Amount],"#,##0.00;(#,##0.00)") VAR _IsLevel2Visible = ISINSCOPE('a360_finance fin_PnL_Template2'[Level_2]) VAR _DisplayDetailCode = SELECTEDVALUE('a360_finance fin_PnL_Template2'[Highlight]) VAR _Revenue = CALCULATE([Actual Amount], REMOVEFILTERS('a360_finance fin_PnL_Template2'), 'a360_finance fin_PnL_Template2'[Level_1] IN {"Sales Revenue"} ) VAR _COGS = CALCULATE([Actual Amount], REMOVEFILTERS('a360_finance fin_PnL_Template2'), 'a360_finance fin_PnL_Template2'[Level_1] IN {"Cost of Products Sold"} ) VAR _CM = CALCULATE([Actual Amount], REMOVEFILTERS('a360_finance fin_PnL_Template2'), 'a360_finance fin_PnL_Template2'[Level_1] IN {"Sales Revenue","Cost of Products Sold"} ) VAR _OCGS = CALCULATE([Actual Amount], REMOVEFILTERS('a360_finance fin_PnL_Template2'), 'a360_finance fin_PnL_Template2'[Level_1] IN {"Other COGS"} ) VAR _SGA = CALCULATE([Actual Amount], REMOVEFILTERS('a360_finance fin_PnL_Template2'), 'a360_finance fin_PnL_Template2'[Level_1] IN {"SGA"} ) VAR _NOPEXP = CALCULATE([Actual Amount], REMOVEFILTERS('a360_finance fin_PnL_Template2'), 'a360_finance fin_PnL_Template2'[Level_1] IN {"Non Operating"} ) VAR _Results = SWITCH(TRUE(), _IsLevel2Visible = TRUE() && _DisplayDetailCode = 1, Blank(), _selectedHeader = "Revenue", FORMAT(_Revenue, "#,##0.00;(#,##0.00)"), _selectedHeader = "Cost of Goods Sold", FORMAT(_COGS,"#,##0.00;(#,##0.00)"), _selectedHeader = "Contribution Margin", FORMAT(_CM,"#,##0.00;(#,##0.00)"), _selectedHeader = "Contribution Margin Percentage", FORMAT((_CM/_Revenue), "#0.0%;(#0.0%)"), _selectedHeader = "Other Cost of Goods Sold", FORMAT(_OCGS,"#,##0.00;(#,##0.00)"), _selectedHeader = "Total COGS", FORMAT(_COGS+_OCGS,"#,##0.00;(#,##0.00)"), _selectedHeader = "Gross Profit", FORMAT(_Revenue+_COGS+_OCGS,"#,##0.00;(#,##0.00)"), _selectedHeader = "Gross Profit Percentage", FORMAT((_Revenue+_COGS+_OCGS)/_Revenue,"#0.0%;(#0.0%)"), _selectedHeader = "Total SGA", FORMAT(_SGA,"#,##0.00;(#,##0.00)"), _selectedHeader = "Total Operating Expenses", FORMAT(_SGA,"#,##0.00;(#,##0.00)"), _selectedHeader = "Operating Income", FORMAT((_Revenue+_COGS+_OCGS+_SGA),"#,##0.00;(#,##0.00)"), _selectedHeader = "Operating Income Percentage", FORMAT((_Revenue+_COGS+_OCGS+_SGA)/_Revenue,"#0.0%;(#0.0%)"), _selectedHeader = "Total Non Operating", FORMAT(_NOPEXP,"#,##0.00;(#,##0.00)"), _selectedHeader = "Net Income", FORMAT((_Revenue+_COGS+_OCGS+_SGA+_NOPEXP),"#,##0.00;(#,##0.00)"), _Actuals //FORMAT(_Actuals, "#,##0.00;(#,##0.00)") ) Return _Results680Views0likes1CommentChange the granularity of the x axis
Hi everyones, I have a slicer of dates whitch allow me to choose the dates between i gonna visualize my chart graph. Currently i show my data per months. I want that my chart graph become dynamic and the conditions gonna be thoses ones: - If the dates choosen are minus one month i want to see my data per weeks - If the dates choosen are minus one week i whant to see my data per days - Else i want to see my data per month I thing that DAX measures can help me to find a solution but i do not know how i can made it. If someone has a solution. Thank youSolved840Views0likes2CommentsDax formula not working
I have created the below dax, to try to get in how many days an order is late. So the loic goes like this: if the order is created before 8pm Monday to Saturday, then it should be fulfilled the same day. If an order has been fulfilled after 8pm then the cut-off will move to the next day, so is like the order was made the next day before 8pm. For Saturday - Sunday orders after 8 the cut-off moves to Monday as Sunday is not a working day. Sunday cannot be counted as failed day, as is not working day. So ideally what I need is how many days have passed since an order that have not been fulfilled on time, for the same day fulfillments works however for some orders created before 8pm and fulfilled the next day or any other day shows like 0 also. I can't figure it out where is the issue. Any help will be highly appreciatted. DaysLate_Express = VAR CreatedTime = MAX(Orders[AdjustedTime]) VAR FulfilledTime = MAX(Orders[Fulfilment Date Adjusted]) -- Get the date values from the datetime VAR CreatedDateOnly = DATEVALUE(CreatedTime) VAR FulfilledDateOnly = DATEVALUE(FulfilledTime) -- Get the created day of the week (Monday = 1, Sunday = 7) VAR CreatedDay = WEEKDAY(CreatedDateOnly, 2) VAR FulfilledDay = WEEKDAY(FulfilledDateOnly, 2) -- Check if the order was created before or after 8 PM VAR IsAfter8PM = IF(HOUR(CreatedTime) >= 20, 1, 0) -- Adjusted created date based on creation time VAR AdjustedCreatedDate = IF( IsAfter8PM = 1, IF(CreatedDay = 6, CreatedDateOnly + 2, -- Saturday after 8 PM moves to Monday IF(CreatedDay = 7, CreatedDateOnly + 1, -- Sunday moves to Monday CreatedDateOnly + 1 -- Weekday after 8 PM moves to the next day )), CreatedDateOnly -- No adjustment for orders created before 8 PM ) -- Check if the fulfilled date is the same day as the adjusted created date VAR IsSameDay = CreatedDateOnly = FulfilledDateOnly -- Calculate the number of days late VAR DaysLate = IF( NOT IsAfter8PM && NOT IsSameDay, DATEDIFF(AdjustedCreatedDate, FulfilledDateOnly, DAY) - DIVIDE(COUNTROWS( FILTER( {1, 2, 3, 4, 5, 6, 7}, -- Days of the week (1 = Monday, ..., 7 = Sunday) [Value] = 7 && [Value] >= WEEKDAY(AdjustedCreatedDate, 2) && [Value] <= WEEKDAY(FulfilledDateOnly, 2) ) ), 1), -- Count the number of Sundays in the range 0 -- Return 0 if the order was fulfilled on the same day or if SLA was met ) -- Return the days late if SLA not met, otherwise 0 RETURN IF(NOT IsSameDay && NOT IsBlank(DaysLate), DaysLate, 0)Solved759Views0likes2CommentsNeed help on DAX
I have two tables - Sales Invoice Lines containing sales transaction and Ledger table containing all financial accounting entries. Both these tables have voucher as common item and hence a relation is created. i need to populate customer's itemized statement in PBI. I have all the details required in sales invoice except GST and PST. In the sales, tax is total whereas tax is split in two lines under GL 271000 and 274000 in the ledger table. when I create a basic measure and/or column for GST and PST, the visual is bringing the GST for all the transaction. but I want ot display the GST and PSt only for the tax impacted line item. my table is as below. in the above, total tax is applicable only on 1 line item. how do I populate the GST and PST only to those lines. my measures are GST = CALCULATE(SUM('TAX Entries'[TRANSACTIONCURRENCYAMOUNT]), FILTER('TAX Entries', 'TAX Entries'[MAINACCOUNTID]="271000")) and PST = CALCULATE(SUM('TAX Entries'[TRANSACTIONCURRENCYAMOUNT]), FILTER('TAX Entries', 'TAX Entries'[MAINACCOUNTID]="274000")) I have tried columns as GSTAX = IF('TAX Entries'[MAINACCOUNTID]="271000", 'TAX Entries'[TRANSACTIONCURRENCYAMOUNT],0) PSTAX = IF('TAX Entries'[MAINACCOUNTID]="274000", 'TAX Entries'[TRANSACTIONCURRENCYAMOUNT],0). please adviseSolved938Views0likes1CommentDAX bar is showing a red error, but not showing any reasoning and won't calculate
I am trying to create a formula that returns a date after original purchase. After I wrote the formula, the red bar in the DAX field is popping at red only at the very end of the formula (outside the last parenthesis), but doesnt give any indication to why. Any suggestions would be much appreicated. Customer Retention % = VAR CurrentMonthAfter = SELECTEDVALUE('Months After'[Value]) VAR CurrentFirstOrderMonth = SELECTEDVALUE('JOD REPORTS'[First Order Date (EOM)]) Return DIVIDE( CALCULATE( DISTINCTCOUNT('JOD REPORTS'[Customer Number]), FILTER( 'JOD REPORTS', EOMONTH('JOD REPORTS'[Order Date],0) = EOMONTH(CurrentFirstOrderMonth,CurrentMonthAfter) ) ), DISTINCTCOUNT('JOD REPORTS'[Customer Number]) )Solved1.6KViews0likes6Comments