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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
zenton
Helper II
Helper II

Last values from measures in a table

Hi,
I need to calculate last values from measures in a table.
The table below shows last 2 dates from 1 year selection.

The Grade and Freq measures and based on MEAN ans STDEV.S calculations
I need measures to calculate
Max Grade to equal a reslut of "B"
Max Freq of the Max Grade to equal a reslut of "High" (if there was a high and low result for Grade "B" the Freq = "Low")

I also need a measure to concatenate the Analyte names for every Grade = Max Grade for the entire selected date range

4/8/2020 has highest grade "C" so Concatenate = Cu, Se, Zn


I can cant filter to last date as this would change the calculations for Grade and Freq as they are dynamically based on the entire selected date range. 

Last 2 dates
zenton_1-1657154967289.png

First 2 dates

zenton_2-1657156660810.png

 

Calulations:

Cont Mean = CALCULATE(DIVIDE([Cont Total],[Cont Count]))

Cont Total = [Historical Total]+[Samples Total]

Cont Count = [Historical Count]+[Samples Count]
 
Cont Std Dev = CALCULATE(STDEV.S('Labware'[Calculated Value]),DATESBETWEEN(Labware[Calendar Date],[Historical Date],[First Sample Date]),ALL(Labware[LIMS Text ID]))
 
Grade = Switch(
True(),
'Labware'[CtA]<3.5,"A",
'Labware'[CtB]<3.5,"B",
'Labware'[CtC]<3.5,"C",
'Labware'[CtD]<3.5,"D",
"E")
 
CtA = CALCULATE(IF([V]>0,[Cp]+(([V]-(MAX('Labware'[A Grade])-1.78*[Cont Std Dev]))/[Cont Std Dev]),IF([V]>MAX('Labware'[A Grade]),7,0)))
 
CtB = CALCULATE(IF([V]>0,[Cp]+(([V]-(MAX('Labware'[B Grade])-1.78*[Cont Std Dev]))/[Cont Std Dev]),IF([V]>MAX('Labware'[B Grade]),7,0)))
 
CtC = CALCULATE(IF([V]>0,[Cp]+(([V]-(MAX('Labware'[C Grade])-1.78*[Cont Std Dev]))/[Cont Std Dev]),IF([V]>MAX('Labware'[C Grade]),7,0)))
 
CtD = CALCULATE(IF([V]>0,[Cp]+(([V]-(MAX('Labware'[D Grade])-1.78*[Cont Std Dev]))/[Cont Std Dev]),IF([V]>MAX('Labware'[D Grade]),7,0)))
 
Thanks Rodney
4 REPLIES 4
zenton
Helper II
Helper II

Hi,

I have made some progrerss with concatenate. Shows correct result in table but as a card result is Blank

 

zenton_0-1657171480648.png

Limiting Contam Test =

VAR VisualValues =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
Labware,
RMD_tlkp_AnolyteMasterList[strColumnLabel],
Labware[Calendar Date],
Labware[LIMS Text ID]
),
"@Grade", Labware[Grade]
),
ALLSELECTED ()
)
VAR MAXGRADE =
MAXX ( VisualValues, [@Grade] )
VAR GRADE =
SWITCH (
TRUE (),
'Labware'[CtA] < 3.5, "A",
'Labware'[CtB] < 3.5, "B",
'Labware'[CtC] < 3.5, "C",
'Labware'[CtD] < 3.5, "D",
"E"
)
RETURN
CALCULATE (
CONCATENATEX (
RMD_tlkp_AnolyteMasterList,
RMD_tlkp_AnolyteMasterList[strLegendName],
", "
),
ALLSELECTED (),
FILTER ( Labware, GRADE = MAXGRADE )
)

Hi @zenton ,

You can create a measure as below and put this new measure onto the card visual:

New Measure =
MAXX (
    GROUPBY (
        Labware,
        Labware[Date],
        Labware[LIMS Text ID],
        Labware[Analyte],
        Labware[Freq],
        Labware[Grade]
    ),
    [Limiting Contam Test]
)

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Hi @v-yiruan-msft

Calculation won't accept Labware[Grade] or Labware[Freq] because they are Measures.
I can try to make simplified pbix file but not easy to do. 80 Tables, 50 relationships and 320 Measures

Thanks Rodney

Hi @v-yiruan-msft 

I have made a simplififed version of PBIX with 2 sample reports

https://drive.google.com/file/d/1UHjufS9u05rF7qXdmsnb_bGGNajBFDa5/view?usp=sharing

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.