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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

Help with splitting in DAX

Nice day
I'm trying to make a split in DAX to get the proportional percentage based on a total, but when I want to make the trade the expected result doesn't come out

Medida 2 = 
/*Variables para seleccionar el idiona*/
VAR Seleccion = SELECTEDVALUE(IDIOMAS[Idioma])
/*Variables para encontrar el ultimo registro en base a la columna de fecha */
var _lastDateDips = MAXX(FILTER(Industrial_Latam,NOT(ISBLANK(Industrial_Latam[Espacio Disponible (m²)]))),Industrial_Latam[Fecha])
/*Varibles donde se guarda el ultimo valor ecncontrado*/
var Total = SUMX(FILTER(Industrial_Latam,Industrial_Latam[Fecha]=_lastDateDips),(Industrial_Latam[Espacio Disponible (m²)])) 
var Porcentaje = SUMX(Industrial_Latam,SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]))/Total
var Percentage_ALLSELECTED =
DIVIDE (
    SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]),Total
)
return Percentage_ALLSELECTED

The DIVIDE part is where I want to get the proportional percentage of each record, but it always marks me 100%

German_043_0-1699291004604.png

What I would like to do is have it divide over the total of "Measure" which would be 253,746, if I add the manual value if it gives me the desired result

Medida 2 = 
/*Variables para seleccionar el idiona*/
VAR Seleccion = SELECTEDVALUE(IDIOMAS[Idioma])
/*Variables para encontrar el ultimo registro en base a la columna de fecha */
var _lastDateDips = MAXX(FILTER(Industrial_Latam,NOT(ISBLANK(Industrial_Latam[Espacio Disponible (m²)]))),Industrial_Latam[Fecha])
/*Varibles donde se guarda el ultimo valor ecncontrado*/
var Total = SUMX(FILTER(Industrial_Latam,Industrial_Latam[Fecha]=_lastDateDips),(Industrial_Latam[Espacio Disponible (m²)])) 
var Porcentaje = SUMX(Industrial_Latam,SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]))/Total
var Percentage_ALLSELECTED =
DIVIDE (
    SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]),253746
)
return Percentage_ALLSELECTED

German_043_1-1699291081515.png

But I'd like to know if I can save the value of the "Total" variable as something fixed or if it only takes that value when I do the division

3 REPLIES 3
Anonymous
Not applicable

Hi @Syndicate_Admin ,

 

Please this measure.

Medida 2 = 
/*Variables para seleccionar el idiona*/
VAR Seleccion = SELECTEDVALUE(IDIOMAS[Idioma])
/*Variables para encontrar el ultimo registro en base a la columna de fecha */
var _lastDateDips = MAXX(FILTER(Industrial_Latam,NOT(ISBLANK(Industrial_Latam[Espacio Disponible (m²)]))),Industrial_Latam[Fecha])
/*Varibles donde se guarda el ultimo valor ecncontrado*/
var Total = SUMX(FILTER(ALL(Industrial_Latam),Industrial_Latam[Fecha]=_lastDateDips),(Industrial_Latam[Espacio Disponible (m²)])) 
var Porcentaje = SUMX(Industrial_Latam,SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]))/Total
var Percentage_ALLSELECTED =
DIVIDE (
    SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]),Total
)
return Percentage_ALLSELECTED

Or you can create a separate total measure.

Total measure = 

var _lastDateDips = MAXX(FILTER(Industrial_Latam,NOT(ISBLANK(Industrial_Latam[Espacio Disponible (m²)]))),Industrial_Latam[Fecha])

var Total = SUMX(FILTER(ALL(Industrial_Latam),Industrial_Latam[Fecha]=_lastDateDips),(Industrial_Latam[Espacio Disponible (m²)])) 

return Total
Medida 2 = 

var Percentage_ALLSELECTED =
DIVIDE (
    SELECTEDVALUE(Industrial_Latam[Espacio Disponible (m²)]),[Total measure]
)
return Percentage_ALLSELECTED

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

 

Syndicate_Admin
Administrator
Administrator

It served me perfectly, if you give me the expected percentages.
But when I put the information in a table it doesn't give me the sum of the percentages that would be 100%, is there a way to do it?

AlexisOlson
Super User
Super User

In the definition of VAR Total, the table Industrial_Latam that you're filtering is not the entire table. It's the portion of that table within the local filter context. In particular, it's filtered by Ciudad just like the numerator is.

 

Try using ALLSELECTED like your last variable implies you would.

 

...
VAR Total =
    SUMX (
        FILTER (
            ALLSELECTED ( Industrial_Latam ),
            Industrial_Latam[Fecha] = _lastDateDips
        ),
        Industrial_Latam[Espacio Disponible (m²)]
    )
...

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.