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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rp2022
Helper II
Helper II

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 ACCEPTED SOLUTION
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, [$] ) )

 

View solution in original post

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.