I´m trying to build a new measure, that show the share of "E_RATPROM"(numerical col) by "NombreCanal" and "fecha_ini_semana" defined by:
fecha_ini_semana = 'calendar'[Date]-WEEKDAY('calendar'[Date],3)
i´m working in a solution using AllExcept or AllSelected, but still cannot build it yet.
i'll appreciate any help..thanks in advance
***Update
i´ve tried the solution of Joao, but the measures dont return as expected;
***Update 2
The issue was im using an aditional column for order, so this column had to be in the ALL expression..like Joao mentioned...
To calculate your total per week, you need to ignore any filters on NombreCanal:
// Measure 1
E_RATPROM Total = SUM('mpq_comercial mqp_sales_bloques'[E_RATPROM])
// Measure 2
total_semana = CALCULATE([E_RATPROM Total], ALL('mpq_comercial mqp_sales_bloques'[NombreCanal])
// Measure 3
ratio = DIVIDE([E_RATPROM Total], [total_semana])
Related
I'm hoping for some help with my measures. My data is quite sensitive so it's not easy to share. I've attempted to mock up as sales so hope it makes sense.
https://1drv.ms/u/s!Ap6q8W-mvm27g-dWehgkV6-p33VVsA?e=bGj3nV
I have written a measure to count the number of resales by TransactionID. I then use a sumx to total the resales by Transaction ID.
I've added this measure to a matrix against Month for Banding and this shows the correct row and column totals.
In the FACT Salestable, I have a field 'Tier'. When I attempt to add 'Tier' to a stacked column chart using the same measures, the data is incorrect. I think it is because the sumx is losing the filter created in the first measure but I don't really understand how to rectify this and have been trying for days!
Is anyone able to identify where my measures are incorrect - Id like to try to understand what exactly I'm asking the measure to do so I know where I'm going wrong for future work! Any help would be very much appreciated - thank you!
MEASURE 1:
CountResales =
Var _Cust = Max (FACTSales[CustomerID])
Var _Date = CALCULATE(min(FACTSales[DateOrigSale]),ALLSELECTED(FACTSales),FACTSales[CustomerID]=_Cust)
Var _ID = CALCULATE(min(FACTSales[CohortID]),ALLSELECTED(FACTSales),FACTSales[CustomerID]=_Cust,FACTSales[DateOrigSale]=_Date)
Var _CountResales =
CALCULATE(DISTINCTCOUNT('DIMReSales transactions'[TransactionID]),
VALUES('DIMReSales transactions'[TransactionID]),'DIMReSales transactions'[CohortID]=_ID,
'DIMReSales transactions'[New Sale]=1)
Return
_CountResales
MEASURE 2:
SumResales = Sumx(values('FACTSales'),[CountResales])
My co-worker has run into an issue finding the amount of days between 2 different entries on a database.
In this database , there can be multiple entires with the same RegNumber , however sometimes the entries are on separate dates.
We would need to fetch the first date (TxrDate) for each RegNr and add it to the "FirstInvDate" column on each line.
Please see the below sample data:
And the below is what he has tried:
Does anyone know if there is an easier way to do this or a specific formula to follow ?
To create a new table use:
FistInvDate =
var __currRegNumber = 'Table'[RegNumber]
return
calculate( min( table[yourDate]), filter(ALL('table'), __currRegNumber = 'Table'[RegNumber]))
I have a table as presented below.
I would like to calculate KPI (#Handled/#Total Offered) and present it using CREATION YEAR MONTH NUMBER on chart but when I am trying to calculate it, it changes to 100% as #handled = #total offered.
#Total Offered = DISTINCTCOUNT(TABLE[REFERENCE_NUMBER])
#Handled = CALCULATE(DISTINCTCOUNT(TABLE1[REFERENCE_NUMBER];TABLE1[IS_CASE_CLOSED])=1))
#Total Offered is presented by CREATION_YEAR_MONTH_NUMBER
#Handled is presented by CURRENT_CASE_STAGE_YEAR_MONTH_NUMBER
I would like to do it as presented below:
Do you have any idea how to solve the case?
Can you try this below 2 Measure? If your coulmn is_case_handled contain always 0 and 1 properly, these simple below measures should work for you.
total_offered = count(your_table_name[is_case_closed])
total_handled = sum((your_table_name[is_case_closed]))
Is there a better way of trying to filter a table and apply a average to the filtered results?
Currently research online articles has brought me to creating a virtual table (CALCULATETABLE) and then a separate measure to AVERAGE the column value I require.
Filtered Table below
filtered_table = CALCULATETABLE ('ReportRawFigures',
ReportRawFigures[days_since_completed] < 29,
ReportRawFigures[3rd_party] = "Bloggs",
ISBLANK(ReportRawFigures[time_to_complete]) = FALSE(),
ISBLANK(ReportRawFigures[last_confirmed_issue]) = FALSE(),
ReportRawFigures[issue_status] = "")
Then a simple measure added:
average = AVERAGE(filtered_table[column])
I'm not very bright... I figured it out.
You create the filtered table, then when you build you visual you simply select the column and chose to average its output..
Hope this helps anyone looking like I first did.
I need to calculate totals using a relationship which doesnt exist. I have the following anonymised tables:
Team
Eng
Job
Hours
My relationships are:
I want to calculate the total hours where Job.EngID = Hours.EngID AND Job.JobID = Hours.JobID, per team. What I want is:
I am part of the way there, but only if I want to show hours by engineer, not by team
HrsMeasure =
CALCULATE (
SUM ( Hours[Hrs] ),
FILTER ( Hours, Hours[EngID] = MAX ( Job[EngID] ) )
)
This gives me:
Is there anything I can do, without changing the data model/relationships?
See below the PBIX file:
https://1drv.ms/u/s!AuiIgc_S9J5JhbgBkRFKyNPYNoxxNA?e=gZBhi2
Cheers for all help
Edit 1 - So I have tried using an inactive relationship between Jobs and Hours but I still get the wrong values. This is done using a concatenated column of JobID/EngID on both Jobs and Hours tables:
HrsMeasureUSERELATIONSHIPJobEng =
CALCULATE (
SUM ( Hours[Hrs] ),
USERELATIONSHIP(Hours[JobEng],Job[JobEng])
)
Hope someone can help me on this as its driving me bonkers!
Cheers
So the answer was to create concatenated columns for JobID/EngID on both the Hours and Jobs tables. Join these two columns using an inactive relationship, and then use a CALCULATE with a USERELATIONSHIP to activate the inactive relationship - this has done the trick:
HrsMeasureUSERELATIONSHIPJobEng =
CALCULATE (
SUM ( Hours[Hrs] ),
USERELATIONSHIP(Hours[JobEng],Job[JobEng])
)