Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
spardadt
Frequent Visitor

Graph a measure changes over time

I have measures that calculate the performance of a supplier base on the time period selected by user. In this example below this is the score for 2022.  Is there anyway i can graph this measure over a period of time? i.e. show the performance in 2019, 2020, 2021, 2022,  etc.

 

spardadt_0-1655470183005.png

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @spardadt ,

I add some data:

vyangliumsft_0-1655799147855.png

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR(MIN('SupplierPerformance'[Receive Date]),MAX('SupplierPerformance'[Receive Date]))

vyangliumsft_1-1655799147856.png

2. Create measure.

# of NCMR 111 =
var _Ven=SELECTEDVALUE('SupplierPerformance'[Vendor ID])
return
COUNTX(FILTER(ALL(NCMR),'NCMR'[Vendor ID]=_Ven),[Vendor ID])
OTD %_1111 =
var _year=SELECTEDVALUE('Date'[Date].[Year])
var _Ven=SELECTEDVALUE('SupplierPerformance'[Vendor ID])
var _count1=COUNTROWS(FILTER(ALL(SupplierPerformance),'SupplierPerformance'[Vendor ID]=_Ven&&YEAR('SupplierPerformance'[Receive Date])=_year&&'SupplierPerformance'[Status]="On Time"))
var _count2=COUNTROWS(FILTER(ALL(SupplierPerformance),'SupplierPerformance'[Vendor ID]=_Ven&&YEAR('SupplierPerformance'[Receive Date])=_year))
return
DIVIDE(_count1,_count2)

3. Result:

The date of the slicer and the date of the line chart are used in the Date table [Date]

Put [OTD %_1111] to Secondary values

vyangliumsft_2-1655799147860.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @spardadt ,

The first Measure[of NCMR 111] means,

First, use Var to define a slicer with the [Vendor ID] field. When a value is selected, Count the selected value.

 

The second measure[OTD %_1111] uses Var to define two slicers, one for [Date] Year, and the other for [Vendor ID]

_count1 means:

Count the number of rows in the SupplierPerformance table when the following conditions are met,

[Vendor ID] = [Vendor ID] value selected by slicer in table,

YEAR('SupplierPerformance'[Receive Date]) is the year to obtain [Receive Date]), the year of [Receive Date] in the table = 'Date'[Date].[Year] The value selected by the slicer

[Status]="On Time" in the table

 

_count2 has the same meaning as _count1, that is, there is one less condition of [Status]="On Time"

 

This is the function link used in the formula, I hope it will help you:

VAR keyword (DAX) - DAX | Microsoft Docs

SELECTEDVALUE function - DAX | Microsoft Docs

COUNTX function (DAX) - DAX | Microsoft Docs

COUNTROWS function (DAX) - DAX | Microsoft Docs

YEAR function (DAX) - DAX | Microsoft Docs

DIVIDE function (DAX) - DAX | Microsoft Docs

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yangliu-msft
Community Support
Community Support

Hi  @spardadt ,

I add some data:

vyangliumsft_0-1655799147855.png

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR(MIN('SupplierPerformance'[Receive Date]),MAX('SupplierPerformance'[Receive Date]))

vyangliumsft_1-1655799147856.png

2. Create measure.

# of NCMR 111 =
var _Ven=SELECTEDVALUE('SupplierPerformance'[Vendor ID])
return
COUNTX(FILTER(ALL(NCMR),'NCMR'[Vendor ID]=_Ven),[Vendor ID])
OTD %_1111 =
var _year=SELECTEDVALUE('Date'[Date].[Year])
var _Ven=SELECTEDVALUE('SupplierPerformance'[Vendor ID])
var _count1=COUNTROWS(FILTER(ALL(SupplierPerformance),'SupplierPerformance'[Vendor ID]=_Ven&&YEAR('SupplierPerformance'[Receive Date])=_year&&'SupplierPerformance'[Status]="On Time"))
var _count2=COUNTROWS(FILTER(ALL(SupplierPerformance),'SupplierPerformance'[Vendor ID]=_Ven&&YEAR('SupplierPerformance'[Receive Date])=_year))
return
DIVIDE(_count1,_count2)

3. Result:

The date of the slicer and the date of the line chart are used in the Date table [Date]

Put [OTD %_1111] to Secondary values

vyangliumsft_2-1655799147860.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

This is exactly what I was looking for even though I have no idea what the codes are doing. I tried to understand SelectedValue but ended up getting confused. If you don't mind would it be possible to explain the code for the 2 measures just a bit? I would like to use this elsewhere too.

 

Either way thank you VERY much for this solution. Very much appreciated!

spardadt
Frequent Visitor

Thanks for your response. Let me clarify:

So I have 2 measures:

1. 

OTD % = DIVIDE(CALCULATE(COUNTROWS(SupplierPerformance), SupplierPerformance[Status] = "On Time"), COUNTROWS(SupplierPerformance))
 
This calculates the On Time Delivery % based on the year and vendor selected by the user 
This measure is based on the following table:
Vendor IDVendor NameReceive DateOrig Del DateStatusDays to Delivery
ABCABC Company12/11/201912/24/2019On Time-13
ABCABC Company12/11/201912/24/2019On Time-13
ABCABC Company3/17/20203/31/2020On Time-14
ABCABC Company6/25/20197/9/2019On Time-14
XYZXYZ Company7/23/20198/6/2019On Time-14
XYZXYZ Company7/26/20198/9/2019On Time-14
ABCABC Company8/26/20199/9/2019On Time-14
 
2.
# of NCMR = COUNTA(NCMR[Vendor Name])
 
Similar to above, this calculates the number of NCMR based on the year and vendor selected by user.
And the measure is based on this table:
 
Issue DateDiscrepancyVendor NameVendor ID
3-May-22Bad connectionABC CompanyABC
22-Jan-22Defect partABC CompanyABC
5-Mar-22Defect partXYZ CompanyXYZ
8-Apr-21Damaged pinABC CompanyABC
1-Feb-21Bad connectionXYZ CompanyXYZ
 
Below is what I envision the graph I want. So the graph for #NCMR would be similar on a separate visual. Essentially this chart will ignore the "Year" input from user but uses the "Vendor" input. But if there's another visual that can show both sets of data together that would be wonderful.
spardadt_0-1655733076505.png

 

 
lbendlin
Super User
Super User

yes, that's pretty much the essence of what Power BI (and any other BI tool) provides.

 

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.