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
PijanMac
Regular Visitor

TOPN DAX without filter

I have an issue with the TOPN method. 

I have a table with a few columns with different Water parameters, they were filled in on different days  (so they have gaps) "InsertDate" column shows these dates. it is also based on different tanks.

TankInsertDateHardnessFAlkalinityphConductivityTemperature
11113-03-24 11:1425.54 6.8880815
11112-03-24 9:2726.07 6.94807.215.3
11111-03-24 10:4224.292.966.97803.515.6
11211-03-24 10:4024.292.966.97803.515.6
11211-03-24 10:3422.91.737.05511.911.5
11211-03-24 10:3026.32.976.94831.915.4
11211-03-24 7:15   7.77211.9


I made a Line charts which show me a trends of value for every parameter based on Insert date. and two slicers for user: "InserDate", and "Tank" to select each tank.

ISUEE: I would like to measure the +/- 3sigma value for each parameter based on only last 10 samples, independently/without the "InserDate" slicer but I can't handle how to remove a filter from this "InserDate" column only for TOPN method.


Here is my code.
+
3sigma_HardnessF_last10samples =
VAR lastxsamples =
    TOPN (10, WaterData,'WaterData'[HardnessF],DESC)
RETURN
    IF(SELECTEDVALUE(WaterData[Location])="Poland",
    CALCULATE(
    AVERAGE('WaterData'[HardnessF])+(3*STDEV.P('WaterData'[HardnessF])),lastxsamples),"")

I will be grateful for any help.
1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @PijanMac ,

 

You can try the following DAX:

Rank =
RANKX(    FILTER(ALL('WaterData'),'WaterData'[Tank]=MAX('WaterData'[Tank])),CALCULATE(SUM('WaterData'[HardnessF])),,DESC)
+3sigma_HardnessF_last10samples =
IF(
    SELECTEDVALUE('WaterData'[Location])="Poland",
    CALCULATE(
        AVERAGE('WaterData'[HardnessF])+
        3*STDEVX.P(
            FILTER(ALL('WaterData'),
            [Rank]<=10),[HardnessF])))

 

 

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.

 

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.