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
valentinaliac
Frequent Visitor

HOW TO SUM A VARIABLE THAT COMES FROM A MEASURE

Hello guys!

 

I have to resume values from 3 different lines of production, which are "Lee Pack", "Rad Pack" and "Manual". To calculate the variable "Velocidad teorica" I use this conditional: 

Velocidad teorica = IF(OR([promedio]=1[promedio]=2), (SUM(Estandares[Rendimiento maquina])/450), IF([promedio]=3,(SUM(Estandares[Rendimiento manual])/450), "0"))

where 1 means "Lee Pack", 2 means "Rad Pack" and 3 means "Manual"

Due to it is a conditional, in the table's total the value shown is the condition if false from the second conditional.

 

Other variable is "Tiempo Teórico" where 

tiempo teorico = sum(Hora[No. Unidades])/[Velocidad teorica]

so if "Velocidad teórica" is 0, then it would show infinite.

 

Lastly, the variable "% CUMPLIMIENTO" is calculated:
% CUMPLIMIENTO = if(([tiempo teorico]/[tiempo real])>100, "0", ([tiempo teorico]/[tiempo real]))

 

My problem is that I can´t visualize the sum of "tiempo teórico", and i Think its because the conditional, same as "velocidad teórica" and "% cumplimiento". Do you know a way to do it?

 

valentinaliac_1-1662566929071.png

The data table is available in the link 

https://docs.google.com/spreadsheets/d/1QcCAdk9oMWi__oWiYaWkTop5OXn5feCg/edit?usp=sharing&ouid=10393...

https://drive.google.com/drive/folders/1BpRDGXwfnV7QKtacQkmnR9kM7pIuxH06?usp=sharing

 

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @valentinaliac ,

 

After my test, the calculation of "New  % Cumplimiento" Works fine, this issue is caused by the aggregation of No.Unidades.

Please check and make sure it is using "Don't Summarize". In your sample, it is using Sum, so the calculation looks wrong.

vjianbolimsft_0-1663834939857.png

vjianbolimsft_1-1663834977687.png

 

Best Regards,

Jianbo Li

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

5 REPLIES 5
v-jianboli-msft
Community Support
Community Support

Hi @valentinaliac ,

 

After my test, the calculation of "New  % Cumplimiento" Works fine, this issue is caused by the aggregation of No.Unidades.

Please check and make sure it is using "Don't Summarize". In your sample, it is using Sum, so the calculation looks wrong.

vjianbolimsft_0-1663834939857.png

vjianbolimsft_1-1663834977687.png

 

Best Regards,

Jianbo Li

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

 

 

v-jianboli-msft
Community Support
Community Support

Hi @valentinaliac ,

 

Based on your sample, I have modified some of your measure, please try:

New velocidad real = SUMX(FILTER('Hora',[Total de horas]<>0),[No. Unidades]/([Total de horas]*60))

New Velocidad teorica =
VAR _a =
    ADDCOLUMNS (
        SUMMARIZE (
            'Hora',
            'Hora'[Hora inicial],
            'Hora'[No. Unidades],
            'Hora'[Empaque]
        ),
        "VT",
            IF (
                OR ( [promedio] = 1, [promedio] = 2 ),
                ( SUM ( Estandares[Rendimiento maquina] ) / 450 ),
                IF ( [promedio] = 3, ( SUM ( Estandares[Rendimiento manual] ) / 450 ), "0" )
            ),
        "PREVISTAS", [PREVISTAS],
        "ProductionReal", [Produccion real]
    )
VAR _b =
    DISTINCT (
        FILTER ( _a, [PREVISTAS] <> BLANK () && [ProductionReal] <> BLANK () )
    )
RETURN
    SUMX ( _b, [VT] )

New % CUMPLIMIENTO =
VAR _a =
    SUMMARIZE (
        'Hora',
        'Hora'[Hora inicial],
        'Hora'[No. Unidades],
        'Hora'[Empaque]
    )
VAR _b =
    ADDCOLUMNS (
        _a,
        "%",
            IF (
                ( [tiempo teorico] / [total minuto] ) > 100,
                "0",
                ( [tiempo teorico] / [total minuto] )
            )
    )
RETURN
    SUMX ( FILTER ( _b, [total minuto] <> 0 && [tiempo teorico] <> BLANK () ), [%] )

Final output:

vjianbolimsft_0-1662974154693.png

Best Regards,

Jianbo Li

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

 

Hi @v-jianboli-msft 

 

Thank you again for your help!

 

I was taking a look to the formulas and found something strange. 

 

valentinaliac_0-1663616319741.png

I have this case where the % Cumplimiento is not being calculated properly. Maybe you can find why?

 

I uploaded the document I'm working on in the same link. 

https://drive.google.com/drive/folders/1BpRDGXwfnV7QKtacQkmnR9kM7pIuxH06

 

Than you!

 

v-jianboli-msft
Community Support
Community Support

Hi @valentinaliac ,

 

What is the relationship between your tables and what is the other measures(such as [tiempo real])?

I can't reproduce your problem just from your source data, need more details about your PBIX file.

Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

Hi, @v-jianboli-msft 

 

Thank you for the interest!

 

I´ve posted the pbix file in the link. Let me know if you have more questions!

https://drive.google.com/drive/folders/1BpRDGXwfnV7QKtacQkmnR9kM7pIuxH06?usp=sharing

 

 

 

Helpful resources

Announcements
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.

Top Solution Authors