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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rp2022
Helper I
Helper I

Measure showing wrong values

 Data:

DateGroupRegPltMat$Qty
11/1/2023PDCKu1m119
12/2/2023PDCNu2m235
2/2/2024PDNu3m346
3/3/2024PDNu4m458
4/4/2024PDKu1m167
5/5/2024DateNu2m281
6/4/2024DateKu5m594
7/5/2024DateNu4m472
8/9/2024DateKu7m723

 

Measure: 

Value $ =

    VAR __group = MAX('Data'[Group])
    VAR __cur_date = MAX('Data'[Date])
    VAR __result = CALCULATE(SUM($),FILTER(ALLSELECTED('Data'),'Data'[Date]<=__cur_date  && 'Data'[Group] = __group))
RETURN __result
Correct Output:
rp2022_0-1714767903077.png

When i use any visual, and just have Date and Value $, everything is okay and works as it should. Once i bring in any other detail into the visual, the numbers are all wrong.

Wrong Output:
rp2022_1-1714767972795.png

Any help is appreciated.

1 REPLY 1
lbendlin
Super User
Super User

You can use SUMMARIZE to adjust to potential other filters.  But that still means you need separate measures.

 

lbendlin_1-1714779805869.png

 

 

Value $ = 
VAR b =
    ADDCOLUMNS (
        SUMMARIZE ( Data, [Date Label],[Reg] ),
        "md", CALCULATE ( MAX ( Data[Date] ) )
    )
VAR c =
    ADDCOLUMNS (
        b,
        "s",
            IF (
                [Date Label] IN { "PD", "PDC" },
                CALCULATE ( SUM ( Data[$] ) ),
                VAR md = [md]
                var r = [Reg]
                RETURN
                    CALCULATE (
                        SUM ( Data[$] ),
                        ALL ( Data ),
                        Data[Date] <= md,
                        Data[Reg] = r,
                        Data[Group] = "Date"
                    )
            )
    )
RETURN
    IF ( HASONEVALUE ( Data[Date Label] ), SUMX ( c, [s] ), SUMX ( Data, [$] ) )

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.