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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rufmau68
Helper I
Helper I

create table with cumulative measures

I

im new in pbi

i need to define a new table in pbi model with this data:

rufmau68_0-1614879515002.png

 

 

i use summarize to define the first 3 columns but i dont know how to calculate the 4th column ("cumulated")

 

thanks falks!

 

1 ACCEPTED SOLUTION

Hi @rufmau68 

I think your CMSCardinis Table is the same as below.

1.png

Then you build a summarize table :SparklineTable_Debug.

SparklineTable_Debug =
SUMMARIZE(CMSCardinis, CMSCardinis[Codice WBS], CMSCardinis[Mese di Rendicontazione].[Date], "Y", sum(CMSCardinis[Giornate]))

2.png

To calculate the running total of Y for each Codice WBS, you could build a measure like 

Basic Measure = 
CALCULATE (
    SUM ( [Y] ),
    FILTER (
        ALL ( SparklineTable_Debug ),
        SparklineTable_Debug[Codice WBS] = MAX ( SparklineTable_Debug[Codice WBS] )
            && SparklineTable_Debug[Date] <= MAX ( SparklineTable_Debug[Date] )
    )
)
Measure_Y_cumulato = SUMX(SparklineTable_Debug,[Basic Measure])

Basic will show wrong Total in table visual, so we need to build a new one basiced on Basic Measure.

1.png

Or you could build a calculated column in SparklineTable_Debug Table.

Column_Y_cumulato =
CALCULATE (
    SUM ( [Y] ),
    FILTER (
        SparklineTable_Debug,
        SparklineTable_Debug[Codice WBS] = EARLIER ( SparklineTable_Debug[Codice WBS] )
            && SparklineTable_Debug[Date] <= EARLIER ( SparklineTable_Debug[Date] )
    )
)

Result:

2.png

You can download the pbix file from this link: create table with cumulative measures

 

Best Regards,

Rico Zhou

 

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

3 REPLIES 3
rufmau68
Helper I
Helper I

i try it,

but dont run

 

when i use sumethinks like 

Y_cumulato =
CALCULATE(SUM([Y]),filter(ALLSELECTED(SparklineTable_Debug[Date]),SparklineTable_Debug[Date]<=MAX(SparklineTable_Debug[Date])))
 
i obtain the value not cumulated (Y=Y_cumulato)
 

Image 20210305_114153_2121.png

 

 if i change formula like this, Y_cumulato = Y grand total 

Image 20210305_114506_2121.png

 

For your information, my tables was generated using this script:
 
SparklineTable_Debug =
SUMMARIZE(CMSCardinis, CMSCardinis[Codice WBS], CMSCardinis[Mese di Rendicontazione].[Date], "Y", sum(CMSCardinis[Giornate]))



Hi @rufmau68 

I think your CMSCardinis Table is the same as below.

1.png

Then you build a summarize table :SparklineTable_Debug.

SparklineTable_Debug =
SUMMARIZE(CMSCardinis, CMSCardinis[Codice WBS], CMSCardinis[Mese di Rendicontazione].[Date], "Y", sum(CMSCardinis[Giornate]))

2.png

To calculate the running total of Y for each Codice WBS, you could build a measure like 

Basic Measure = 
CALCULATE (
    SUM ( [Y] ),
    FILTER (
        ALL ( SparklineTable_Debug ),
        SparklineTable_Debug[Codice WBS] = MAX ( SparklineTable_Debug[Codice WBS] )
            && SparklineTable_Debug[Date] <= MAX ( SparklineTable_Debug[Date] )
    )
)
Measure_Y_cumulato = SUMX(SparklineTable_Debug,[Basic Measure])

Basic will show wrong Total in table visual, so we need to build a new one basiced on Basic Measure.

1.png

Or you could build a calculated column in SparklineTable_Debug Table.

Column_Y_cumulato =
CALCULATE (
    SUM ( [Y] ),
    FILTER (
        SparklineTable_Debug,
        SparklineTable_Debug[Codice WBS] = EARLIER ( SparklineTable_Debug[Codice WBS] )
            && SparklineTable_Debug[Date] <= EARLIER ( SparklineTable_Debug[Date] )
    )
)

Result:

2.png

You can download the pbix file from this link: create table with cumulative measures

 

Best Regards,

Rico Zhou

 

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

amitchandak
Super User
Super User

@rufmau68 , Assume you measure is sum measure


Something like   sum(Table[Some value])

 

Try a new measure for Cumulative

calculate([measure], filter(allselected(Table]), table[category] = max(Table[category]) && table[data] <= max(Table[data])))

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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