Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Experts
I am trying to creat the following in Power BI for the Y Values (dates) as shown in the image below. The image below is an example that someone has done in excel. The question is how would you do this in power BI
image 1.
i just need the result from the table which in excel is sum D4:015 = -44 (based on material_id using my data set)
Date Table in Power BI
sample power bi file.
https://www.dropbox.com/s/1jq4ddeuy3nxpzq/apples.pbix?dl=0
Solved! Go to Solution.
If the error message is about SUMMARIZECOLUMNS and ADDMISSINGITEMS not being allowed in the current context, that's an issue with SUMMARIZECOLUMNS not playing well with slicers on multiple columns.
I re-wrote the measure to use the old ADDCOLUMNS style pattern that was used before SUMMARIZECOLUMNS was introduced:
MK-Stat = VAR ComplaintsByFiscalMo = ADDCOLUMNS(VALUES(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", CALCULATE(COUNTROWS(PMS_COMPLAINT))) RETURN SUMX(ComplaintsByFiscalMo, SUMX(ComplaintsByFiscalMo, IF([FISCAL_MON_START_DT]>EARLIER([FISCAL_MON_START_DT])&&[CountComplaints]>EARLIER([CountComplaints]), 1, IF([FISCAL_MON_START_DT]>EARLIER([FISCAL_MON_START_DT])&&[CountComplaints]<EARLIER([CountComplaints]), -1)) ) )
I've also re-uploaded the change in the .pbix file on Google Drive. The same link will download the newer version.
The formula seems pretty easy. Take the count of rows that are below than the current row, and evaluate them for positive/zero/negative results. To break it down, if all you have is the data in A4:A15, get a count of values that have a higher row# and that are higher than the current value, and subtract a count of values that have a higher row# and are lower than the current value. Repeat for each row.
My question is how is the order of the data determined? Right now, it seems arbitrary, but changing the order would definitely give a different result. In this pseudocode, I've just given a numerical index to each data point, to keep the order as you presented it. You can replace that with any sortable column that indicates the order of the values.
MKSum = SUMX( 'Data', CALCULATE(COUNTROWS(FILTER(ALL(Data), Data[Index]>SELECTEDVALUE('Data'[Index]) && Data[Value] > SELECTEDVALUE(Data[Value])))) - CALCULATE(COUNTROWS(FILTER(ALL(Data), Data[Index]>SELECTEDVALUE('Data'[Index]) && Data[Value] < SELECTEDVALUE(Data[Value])))) )
Here's the data table I used to get a result of -44:
Data:
Value | Index |
6.8 | 1 |
5.9 | 2 |
5.7 | 3 |
5.5 | 4 |
5.5 | 5 |
4.5 | 6 |
4 | 7 |
5.1 | 8 |
4.5 | 9 |
4.5 | 10 |
3.3 | 11 |
4.8 | 12 |
What is a "Y value" from the table above? A year value? Some sort of calculated value? The data table you shared looks like a date dimension, so doesn't have any Material ID associated with the data, nor any actual data to calculate a "Y value" from.
You're fine using MATERIAL_ID as your sorting column, as long as that's the order you want the data in. I would have assumed that MATERIAL_ID is more of a group by field as opposed to an ordering field, but it could be both. From your original example, I wasn't sure why 6.8 came first, and 5.9 second. If that's because the MATERIAL_ID for 6.8 is less than the MATERIAL_ID of 5.9, that's fine.
Changing the date range of the current period should work fine for whatever visual you have, since that will limit the input data.
I would try and help more directly with the .pbix you shared, but there's SO MUCH data in there, I don't know what fields to use for what. That's why my previous answer used the very simple data set with 12 values that you shared. You should be able to just replace Data[Index] and Data[Value] with the fields/measures that you actually want to use for calculations.
What is a "Y value" from the table above? Y Vlaue just meand 12 months period in above table
A year value? Some sort of calculated value? The data table you shared looks like a date dimension, so doesn't have any Material ID associated with the data, nor any actual data to calculate a "Y value" from. the material ID is in the main FACT table PMS_Complaints
You're fine using MATERIAL_ID as your sorting column, as long as that's the order you want the data in. I would have assumed that MATERIAL_ID is more of a group by field as opposed to an ordering field, but it could be both. From your original example, I wasn't sure why 6.8 came first, and 5.9 second. If that's because the MATERIAL_ID for 6.8 is less than the MATERIAL_ID of 5.9, that's fine. - my original example was based on a totally different data set and was merely used as an example, as i wanted to replicate that method on the bigger picture PMS_Complaints
Changing the date range of the current period should work fine for whatever visual you have, since that will limit the input data.
I would try and help more directly with the .pbix you shared, but there's SO MUCH data in there, I don't know what fields to use for what. That's why my previous answer used the very simple data set with 12 values that you shared. You should be able to just replace Data[Index] and Data[Value] with the fields that you actually want to use for calculations. - the master FACT table is PMS_Complaints and i am trying to group the data using Material_ID and somehow work out the mann Kandell p-values (see link below)
http://www.real-statistics.com/time-series-analysis/time-series-miscellaneous/mann-kendall-test/
OK. I'm not a statistics person, so let's break this down. If I've gotten any of the top-level bullet points wrong, please let me know.
Also, if you copy-paste this to answer the questions, could you change the text color of your responses so that it stands out more? I don't want to miss anything.
OK. I'm not a statistics person, so let's break this down. If I've gotten any of the top-level bullet points wrong, please let me know.
There we go. Now that I know what values you want input into the MK test, we can use it in the context of your report:
MK-Stat = VAR ComplaintsByFiscalMo = SUMMARIZECOLUMNS(PMS_COMPLAINT[FISCAL_MON_START_DT],"MonthGroup", SELECTEDVALUE(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", COUNTROWS(PMS_COMPLAINT)) RETURN SUMX(ComplaintsByFiscalMo, SUMX(ComplaintsByFiscalMo, IF([MonthGroup]>EARLIER([MonthGroup])&&[CountComplaints]>EARLIER([CountComplaints]), 1, IF([MonthGroup]>EARLIER([MonthGroup])&&[CountComplaints]<EARLIER([CountComplaints]), -1)) ) )
sorry to be a pain
but i cannot get this to work, can you kindly upload the pbix, please.
HI
do i add this as new table or a measure into PMS_Complaints table????
I created this as a measure in your _Measures table.
Here's the .pbix file. The measure is MK-Stat, and I've displayed it in a card in the bottom right, just under MATERIAL_ID_FREQUENCY
What error are you receiving?
If the error message is about SUMMARIZECOLUMNS and ADDMISSINGITEMS not being allowed in the current context, that's an issue with SUMMARIZECOLUMNS not playing well with slicers on multiple columns.
I re-wrote the measure to use the old ADDCOLUMNS style pattern that was used before SUMMARIZECOLUMNS was introduced:
MK-Stat = VAR ComplaintsByFiscalMo = ADDCOLUMNS(VALUES(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", CALCULATE(COUNTROWS(PMS_COMPLAINT))) RETURN SUMX(ComplaintsByFiscalMo, SUMX(ComplaintsByFiscalMo, IF([FISCAL_MON_START_DT]>EARLIER([FISCAL_MON_START_DT])&&[CountComplaints]>EARLIER([CountComplaints]), 1, IF([FISCAL_MON_START_DT]>EARLIER([FISCAL_MON_START_DT])&&[CountComplaints]<EARLIER([CountComplaints]), -1)) ) )
I've also re-uploaded the change in the .pbix file on Google Drive. The same link will download the newer version.
You tell me. I figured it was just the start date of the current fiscal month that the complain was registered, and that if you changed your filter, it would include values from other periods.
So it should apply to whatever the filtered period is I guess? I haven't messed with however you set that up.
Hi Mcmahan...
did you get my post on the frequncy question?
I'm able to get the same p-values, though I had to set up a new measure that mimicked the calculation the website was doing to get the value in P19. They only match when you don't have any filters applied. I assume this is how they were originally calculated.
Also, due to an overflow error, the p-value can't be displayed in the Product Complaints Totals with Trend Direction matrix, so I displayed it in a final card. You can check that it's getting the correct value by selecting a single product from the matrix.
I've re-uploaded the new file to GDrive, feel free to test it out!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |