Forum Discussion
Finding values from related tables for Dax and Field parameter values not shown
- Mar 10, 2024
As for the first part. When we select Category Main (Budget or Target or Nothing) we pick-up all categories related to selected main. Thus for the Budget or Target list of categories finally applied for filtering is {Unit, Cost}. There is no Carbon in such list, it appears only Main is not filtered.
With first case filtered Parameter table is empty, Carbon is not selectable and result is blank.
In general, for Carbon calculating we need to remove filter context from Category Main.
In case of parameter table we can't remove shadow filter content since internally DAX makes grouping and we can't get content from the column grouped by other column.
As workaround we may modify ShowValues as
VAR SelectedParameter = SELECTEDVALUE ( 'Parameter 3'[Category] ) VAR nRows = COUNTROWS('Parameter 3')+0 VAR Result = SWITCH ( SelectedParameter, "Units", SUM ( DataInvoice[Units] ), "Cost", SUM ( DataInvoice[Cost] ), "Carbon", [Carbon tCO2e] ) RETURN IF(nRows = 0, [Carbon tCO2e], Result )
However, not very reliable from maintenance point of view if we will be modifying parameters configuration.
See results on Page 3
File is here TechComm - OneDrive (live.com)
As for the first part. When we select Category Main (Budget or Target or Nothing) we pick-up all categories related to selected main. Thus for the Budget or Target list of categories finally applied for filtering is {Unit, Cost}. There is no Carbon in such list, it appears only Main is not filtered.
With first case filtered Parameter table is empty, Carbon is not selectable and result is blank.
In general, for Carbon calculating we need to remove filter context from Category Main.
In case of parameter table we can't remove shadow filter content since internally DAX makes grouping and we can't get content from the column grouped by other column.
As workaround we may modify ShowValues as
VAR SelectedParameter =
SELECTEDVALUE ( 'Parameter 3'[Category] )
VAR nRows = COUNTROWS('Parameter 3')+0
VAR Result =
SWITCH (
SelectedParameter,
"Units", SUM ( DataInvoice[Units] ),
"Cost", SUM ( DataInvoice[Cost] ),
"Carbon", [Carbon tCO2e]
)
RETURN
IF(nRows = 0, [Carbon tCO2e], Result )
However, not very reliable from maintenance point of view if we will be modifying parameters configuration.
See results on Page 3
File is here TechComm - OneDrive (live.com)
- Excellove15Mar 11, 2024Iron Contributor
Hi SergeiBaklan
Many thanks for your response Sir!
Amazing workaround and a beautiful solution with crisp explanation and wonderful screenshots.
I am always big fan of your patience & deep understanding of technical stuffs.
You are really a super hero for me and am learning a lot from you sir!
I will close this query and mark your solution as best response!
Wish to stay in touch with you sir! wish to stay connected with you on email & linkedin
My email id is email address removed for privacy reasons
Please let me know if you need anything from my end and am happy to help always!
Wish you a good health and happy long life
- SergeiBaklanMar 11, 2024Diamond Contributor
Excellove15 , you are welcome, glad to help.