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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
walkra
Helper III
Helper III

Subtract two dimensions that receive the data and filters from the same table.

Hi, How Are You?. Again, I appeal to you for great help.
I created two dimensions ("FactorOccupac" and "FactorOccupac1") that they perform two calculations of two different dates. All data is taken from a single table and the filters on the page come from that table. What happens that, in two graphics cards the results are presented correctly, but when I want to subtract those two dimensions (in a third dimension, "DifFO1FO2") to obtain the difference, the result of "FactorOcupac" is blank, although in its graphic card continues to appear correctly (therefore, the result of the difference is wrong).

The idea is to have the flexibility to filter any date to present the data of the chosen.

I read that you can not subtract the results of the graphic cards in a different way. Is that so?. 

What I can do?.

Untitled8.png

Thank you very Much!!

 

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

Hi @walkra 

Tested with your pbix shared in previous post as below:

Create two tables

one table named "date1"

date1 = 
ADDCOLUMNS(CALENDAR(MIN('TMSEGX (2)'[FechaDocumento]),MAX('TMSEGX (2)'[FechaDocumento])),"year/month",FORMAT([Date],"mmmm yyyy"))

another table named "date2"

date2 =
 ADDCOLUMNS(CALENDAR(MIN('TMSEGX (2)'[FechaDocumento]),MAX('TMSEGX (2)'[FechaDocumento])),"year/month",FORMAT([Date],"mmmm yyyy"))

Note: don't create any relationship for these two tables.

 

Then add "year/month" columns from "date1" and "date2" to two slicers.

Create measures in "TMSEGX (2)" table

Measure = 
CALCULATE(SUM('TMSEGX (2)'[Columna]),FILTER(ALLSELECTED('TMSEGX (2)'),'TMSEGX (2)'[Column]=SELECTEDVALUE(date1[year/month])))/[Valor CantidadEmpleados]

Measure 2 = 
CALCULATE(SUM('TMSEGX (2)'[Columna]),FILTER(ALLSELECTED('TMSEGX (2)'),'TMSEGX (2)'[Column]=SELECTEDVALUE(date2[year/month])))/[Valor CantidadEmpleados]

Measure 3 = [Measure]/[Measure 2] (if you'd like to subtract them, use "-" instead)

7.png

Best Regards
Maggie

 

Community Support Team _ Maggie 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

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @walkra 

Tested with your pbix shared in previous post as below:

Create two tables

one table named "date1"

date1 = 
ADDCOLUMNS(CALENDAR(MIN('TMSEGX (2)'[FechaDocumento]),MAX('TMSEGX (2)'[FechaDocumento])),"year/month",FORMAT([Date],"mmmm yyyy"))

another table named "date2"

date2 =
 ADDCOLUMNS(CALENDAR(MIN('TMSEGX (2)'[FechaDocumento]),MAX('TMSEGX (2)'[FechaDocumento])),"year/month",FORMAT([Date],"mmmm yyyy"))

Note: don't create any relationship for these two tables.

 

Then add "year/month" columns from "date1" and "date2" to two slicers.

Create measures in "TMSEGX (2)" table

Measure = 
CALCULATE(SUM('TMSEGX (2)'[Columna]),FILTER(ALLSELECTED('TMSEGX (2)'),'TMSEGX (2)'[Column]=SELECTEDVALUE(date1[year/month])))/[Valor CantidadEmpleados]

Measure 2 = 
CALCULATE(SUM('TMSEGX (2)'[Columna]),FILTER(ALLSELECTED('TMSEGX (2)'),'TMSEGX (2)'[Column]=SELECTEDVALUE(date2[year/month])))/[Valor CantidadEmpleados]

Measure 3 = [Measure]/[Measure 2] (if you'd like to subtract them, use "-" instead)

7.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Beautiful!! Divine!!. You do not know how many hours I spent trying to solve this problem. In addition, you teach me to create tables from code. One more question: why should we create the "Column" field based on the same information as the "DateDocument" field (only to know the logic).

 

An impeccable and very didactic explanation!

 

Thank You, Very Much!!! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.