Forum Discussion
Data comparison from one column / slicer
- Anonymous2 years ago
Hi Anonymous ,
I created a sample pbix file(see the attachment), please check if that is what you want.
Qty = VAR _minsource = MIN ( 'OPI_Database'[Source ID] ) VAR _maxsource = MAX ( 'OPI_Database'[Source ID] ) VAR _minqty = CALCULATE ( SUM ( 'QCPW Data'[Quantity] ), FILTER ( 'QCPW Data', 'QCPW Data'[Source ID] = _minsource ) ) VAR _maxqty = CALCULATE ( SUM ( 'QCPW Data'[Quantity] ), FILTER ( 'QCPW Data', 'QCPW Data'[Source ID] = _maxsource ) ) RETURN IF ( ISINSCOPE ( 'OPI_Database'[Source.Name] ), SUM ( 'QCPW Data'[Quantity] ), _maxqty - _minqty )SPrice = VAR _minsource = MIN ( 'OPI_Database'[Source ID] ) VAR _maxsource = MAX ( 'OPI_Database'[Source ID] ) VAR _minprice = CALCULATE ( SUM ( 'QCPW Data'[Price] ), FILTER ( 'QCPW Data', 'QCPW Data'[Source ID] = _minsource ) ) VAR _maxprice = CALCULATE ( SUM ( 'QCPW Data'[Price] ), FILTER ( 'QCPW Data', 'QCPW Data'[Source ID] = _maxsource ) ) RETURN IF ( ISINSCOPE ( 'OPI_Database'[Source.Name] ), SUM ( 'QCPW Data'[Quantity] ), _maxprice - _minprice )Best Regards
It is possible to create a comparison between two chosen datasets in Power BI. You can do this by creating a measure that calculates the difference between the two datasets. Here is an example of a measure that calculates the difference between the values of two columns, representing two different datasets:
Difference =
SUMX(
FILTER(
'Table',
'Table'[Column1] = "2024 AC Price"
),
'Table'[Value]
) - SUMX(
FILTER(
'Table',
'Table'[Column1] = "2023 AC Price"
),
'Table'[Value]
)In this measure, 'Table' is the name of the table containing the data, 'Table'[Column1] is the column containing the names of the datasets, and 'Table'[Value] is the column containing the values of the datasets. The measure calculates the sum of the values for the "2024 AC Price" dataset and subtracts the sum of the values for the "2023 AC Price" dataset.
Please note that you will need to replace 'Table', 'Table'[Column1], and 'Table'[Value] with the actual names of your table and columns. Also, make sure that the names of the datasets in the measure match the names of the datasets in your table.
Best regards,
Johannes
Thank you, Johannes!
I understand your logic, but my goal is to make datasets variable using slicer, so that i can compare not only 2024 AC and 2023 AC, but 2024 OB and RF3 as well.