Forum Discussion
Issues migrating Dax formulas from Tabular model to Power Bi desktop --- Report Builder to Power Bi
For this problem I am using a TABULAR/SSAS MODEL and MUST move it FROM Report Builder TO Power Bi. I have copied over the DAX to structure it - but it is not calculating correctly.
HOW REPORT BUILDER IS SET UP:
I must filter multiple values in both PhysicianOrganization and then PCPLocation I am working on a Paginated report in REPORT BUILDER that the user would like to:
- Select date (Month/Year) then the PhysicianOrganization then the PCPLocation to have a pdf for that location and others only. (PhysicianOrganization must filter PCPLocation) Below the Physician Organization does not filter on the PCPLocation and it a must!
- Dataset1 will be filtered by PhysicianOrganization, PCPLocation and Date (monthly reporting) which used month and year and PhysicianLocation Dataset which has the Physician Organization & PCPLocation values which the Parameters connect to. Below is what the report data looks like and I added the DAX fields below (this is from a CUBE or Tabular connection) I am thinking I should put the Year and Month in the PhysicianLocation dataset?
- I have 3 datasets that do the following:
- Filter the PCPLocation by PhysicianOrganization but when I run my report I do not see data:
I’ve 3 datasets:
- PO – First Filter
- PCPLocation – 2nd filter
- Main Dataset which has the month/year parameter
My DAX Code is below:
4 Parameters 1) PO Parameter Referencing Query 1
EVALUATE
DISTINCT (
SELECTCOLUMNS (
'Providers',
"PhysicianOrganization", 'Providers'[PhysicianOrganization]
)
)
2) EVALUATE SUMMARIZECOLUMNS('Providers'[PCPLocation], RSCustomDaxFilter(@ProvidersPhysicianOrganization,EqualToCondition,[Providers].[PhysicianOrganization],String))
3) Year and Month are specified Values:
4)) Main dataset (in report builder)
EVALUATE
VAR FilteredTable =
SUMMARIZECOLUMNS(
'Providers'[PhysicianOrganization],
'Providers'[PCPLocation],
'Patients'[InsuranceType],
'DateDim'[Year],
'DateDim'[MonthNameAbbreviation],
FILTER(
VALUES('DateDim'[Year]),
'DateDim'[Year] = VALUE(@Year)
),
FILTER(
VALUES('DateDim'[MonthNameAbbreviation]),
'DateDim'[MonthNameAbbreviation] = @Month
),
FILTER(
VALUES('Patients'[Populations]),
'Patients'[Populations] = "GM"
),
FILTER(
VALUES('Providers'[PhysicianOrganization]),
'Providers'[PhysicianOrganization] = @PhysicianOrganization
),
FILTER(
VALUES('Providers'[HFPN_GMCC_Flag]),
'Providers'[HFPN_GMCC_Flag] = "Yes"
),
FILTER(
VALUES('Outpatient'[OfficeVisitEncounter]),
'Outpatient'[OfficeVisitEncounter] = "Virtual Visit"
)
)
RETURN
ADDCOLUMNS(
FilteredTable,
"UniquePatients", [UniquePatients],
"TotalCostYTD", [TotalCostYTD],
"MemberMonthsYTD", [MemberMonthsYTD],
"Admits1000YTD", [Admits1000YTD],
"AnnualWellnessExamNumerator", [AnnualWellnessExamNumerator],
"AnnualWellnessExamDenominator", [AnnualWellnessExamDenominator],
"AnnualWellnessExamRate", [AnnualWellnessExamRate],
"AntidepressantMedicationAcutePhaseNumerator", [AntidepressantMedicationAcutePhaseNumerator],
"AntidepressantMedicationAcutePhaseDenominator", [AntidepressantMedicationAcutePhaseDenominator],
"AntidepressantMedicationAcutePhaseRate", [AntidepressantMedicationAcutePhaseRate],
"ERVisitsYTD", [ERVisitsYTD],
"ERVisits1000YTD", [ERVisits1000YTD],
"BloodPressureNumerator", [BloodPressureNumerator],
"BloodPressureDenominator", [BloodPressureDenominator],
"BloodPressureRate", [BloodPressureRate],
"DAWNumerator", [DAWNumerator],
"DAWDenominator", [DAWDenominator],
"DAWFillRate", [DAWFillRate],
"DiabetesHbA1cLessThan8Numerator", [DiabetesHbA1cLessThan8Numerator],
"DiabetesDenominator", [DiabetesDenominator],
"DiabetesHbA1cLessThan8Rate", [DiabetesHbA1cLessThan8Rate],
"FuInNumerator", [FuInNumerator],
"FuInDenominator", [FuInDenominator],
"F/U Hospitalization for Mental Illness", [F/U Hospitalization for Mental Illness],
"ReadmitsYTD", [ReadmitsYTD],
"ReadmitsYTDRate", [ReadmitsYTD%],
"AdmitsYTD", [AdmitsYTD],
"AllowedCost", [AllowedCost],
"AllowedCostYTD", [AllowedCostYTD],
"AllowedPMPMYTD", [AllowedPMPMYTD],
"BreastCancerScreeningNumerator", [BreastCancerScreeningNumerator],
"BreastCancerScreeningDenominator", [BreastCancerScreeningDenominator],
"BreastCancerScreeningRate", [BreastCancerScreeningRate],
"ColorectalCancerScreeningDenominator", [ColorectalCancerScreeningDenominator],
"ColorectalCancerScreeningNumerator", [ColorectalCancerScreeningNumerator],
"ColorectalCancerScreeningRate", [ColorectalCancerScreeningRate],
"ERVisitsRate", [ERVisitsYTDMoreThan5Visits1000],
"ERVisitsNumerator", [ERVisitsYTDMoreThan5Visits],
"VirtualNumerator", [OutpatientUtilYTD],
"VirtualRate", [OutpatientUtil1000YTD],
"DepressionScreeningNumerator", [DepressionScreeningNumerator],
"DepressionScreeningDenominator", [DepressionScreeningDenominator],
"DepressionScreeningRate", [DepressionScreeningRate],
"DepressionPositiveScreenNumerator", [DepressionPositiveScreenNumerator],
"DepressionPositiveScreenDenominator", [DepressionPositiveScreenDenominator],
"DepressionPositiveScreenRate", [DepressionPositiveScreenRate],
"CervicalCancerNumerator", [CervicalCancerNumerator],
"CervicalCancerDenominator", [CervicalCancerDenominator],
"CervicalCancerRate", [CervicalCancerRate],
"GenericNumeratorYTD", [GenericNumeratorYTD],
"GenericDenominatorYTD", [GenericDenominatorYTD],
"GenericFillRateYTD", [GenericFillRateYTD],
"LowBackPainImaging18to64Numerator", [LowBackPainImaging18to64Numerator],
"LowBackPainImaging18to64Denominator", [LowBackPainImaging18to64Denominator],
"LowBackPainImaging18to64InverseRate", [LowBackPainImaging18to64InverseRate],
"Zero", 0
)
What I have in Power Bi is below:
4 tables using DAX from Report Builder:
EVALUATE
VAR FilteredTable =
SUMMARIZECOLUMNS(
'DateDim'[Year],
'DateDim'[MonthName],
'Providers'[PhysicianOrganization],
'Providers'[PCPLocation],
// Ensure only rows with years from 2022 onward are considered
FILTER(
'DateDim',
'DateDim'[Year] >= 2022
),
// Only include patients in the "GM" population with combined InsuranceType
FILTER(
'Patients',
( 'Patients'[InsuranceType] = "Attributed" || 'Patients'[InsuranceType] = "Product" ) &&
'Patients'[Populations] = "GM"
),
// Ensure only rows where HFPN_GMCC_Flag is "Yes"
FILTER(
'Providers',
'Providers'[HFPN_GMCC_Flag] = "Yes"
),
// Only include encounters of type "Virtual Visit"
FILTER(
'Outpatient',
'Outpatient'[OfficeVisitEncounter] = "Virtual Visit"
)
)
RETURN
ADDCOLUMNS(
FilteredTable,
"UniquePatients", [UniquePatients],
"TotalCostYTD", [TotalCostYTD],
"MemberMonthsYTD", [MemberMonthsYTD],
"Admits1000YTD", [Admits1000YTD],
"AnnualWellnessExamNumerator", [AnnualWellnessExamNumerator],
"AnnualWellnessExamDenominator", [AnnualWellnessExamDenominator],
"AnnualWellnessExamRate", [AnnualWellnessExamRate],
"ERVisitsYTD", [ERVisitsYTD],
"ERVisits1000YTD", [ERVisits1000YTD],
"BloodPressureNumerator", [BloodPressureNumerator],
"BloodPressureDenominator", [BloodPressureDenominator],
"BloodPressureRate", [BloodPressureRate],
"DAWNumerator", [DAWNumerator],
"DAWDenominator", [DAWDenominator],
"DAWFillRate", [DAWFillRate],
"DiabetesHbA1cLessThan8Numerator", [DiabetesHbA1cLessThan8Numerator],
"DiabetesDenominator", [DiabetesDenominator],
"DiabetesHbA1cLessThan8Rate", [DiabetesHbA1cLessThan8Rate],
"FuInNumerator", [FuInNumerator],
"FuInDenominator", [FuInDenominator],
"F/U Hospitalization for Mental Illness", [F/U Hospitalization for Mental Illness],
"ReadmitsYTD", [ReadmitsYTD],
"ReadmitsYTDRate", [ReadmitsYTD%],
"AdmitsYTD", [AdmitsYTD],
"AllowedCost", [AllowedCost],
"AllowedCostYTD", [AllowedCostYTD],
"AllowedPMPMYTD", [AllowedPMPMYTD],
"BreastCancerScreeningNumerator", [BreastCancerScreeningNumerator],
"BreastCancerScreeningDenominator", [BreastCancerScreeningDenominator],
"BreastCancerScreeningRate", [BreastCancerScreeningRate],
"ColorectalCancerScreeningDenominator", [ColorectalCancerScreeningDenominator],
"ColorectalCancerScreeningNumerator", [ColorectalCancerScreeningNumerator],
"ColorectalCancerScreeningRate", [ColorectalCancerScreeningRate],
"ERVisitsRate", [ERVisitsYTDMoreThan5Visits1000],
"ERVisitsNumerator", [ERVisitsYTDMoreThan5Visits],
"VirtualNumerator", [OutpatientUtilYTD],
"VirtualRate", [OutpatientUtil1000YTD],
"DepressionScreeningNumerator", [DepressionScreeningNumerator],
"DepressionScreeningDenominator", [DepressionScreeningDenominator],
"DepressionScreeningRate", [DepressionScreeningRate],
"DepressionPositiveScreenNumerator", [DepressionPositiveScreenNumerator],
"DepressionPositiveScreenDenominator", [DepressionPositiveScreenDenominator],
"DepressionPositiveScreenRate", [DepressionPositiveScreenRate],
"CervicalCancerNumerator", [CervicalCancerNumerator],
"CervicalCancerDenominator", [CervicalCancerDenominator],
"CervicalCancerRate", [CervicalCancerRate],
"GenericNumeratorYTD", [GenericNumeratorYTD],
"GenericDenominatorYTD", [GenericDenominatorYTD],
"GenericFillRateYTD", [GenericFillRateYTD],
"LowBackPainImaging18to64Numerator", [LowBackPainImaging18to64Numerator],
"LowBackPainImaging18to64Denominator", [LowBackPainImaging18to64Denominator],
"LowBackPainImaging18to64InverseRate", [LowBackPainImaging18to64InverseRate],
"Zero", 0
)
Table 2 – PCPLocation Table
EVALUATE
SUMMARIZECOLUMNS(
'Providers'[PCPLocation],
'DateDim'[Year],
'DateDim'[MonthName],
FILTER(
ALL('Providers'),
'Providers'[PhysicianOrganization] IN VALUES('Providers'[PhysicianOrganization])
),
FILTER(
ALL('DateDim'),
'DateDim'[Year] IN VALUES('DateDim'[Year]) &&
'DateDim'[MonthName] IN VALUES('DateDim'[MonthName])
)
)
Table 3 – PhysicianOrganization (filter)
EVALUATE
SUMMARIZECOLUMNS(
'Providers'[PhysicianOrganization]
)
Table 4 - Datedim
EVALUATE
SUMMARIZECOLUMNS(
'DateDim'[Year],
'DateDim'[MonthName],
FILTER(
'DateDim',
'DateDim'[Year] > 2022
))
2 Replies
- AnonymousNot applicable
Hi Karolina411 ,
In Power BI, you could use slicer to replace the parameter in report builder.
Adding slicers to the report page allows the user to interactively select the year, month, doctor's organisation etc.
- Year slicer: Use
DateDim[Year] - Month slicer: Use
DateDim[MonthName]
Then try the following dax to create a calcualted table:MyCalculatedTable = VAR FilteredTable = SUMMARIZECOLUMNS( 'Providers'[PhysicianOrganization], 'Providers'[PCPLocation], 'Patients'[InsuranceType], 'DateDim'[Year], 'DateDim'[MonthName], FILTER('DateDim', 'DateDim'[Year] >= 2022), FILTER('Patients', 'Patients'[Populations] = "GM"), FILTER('Providers', 'Providers'[HFPN_GMCC_Flag] = "Yes"), FILTER('Outpatient', 'Outpatient'[OfficeVisitEncounter] = "Virtual Visit") ) RETURN ADDCOLUMNS( FilteredTable, "UniquePatients", [UniquePatients], "TotalCostYTD", [TotalCostYTD], "MemberMonthsYTD", [MemberMonthsYTD], "Admits1000YTD", [Admits1000YTD], "AnnualWellnessExamNumerator", [AnnualWellnessExamNumerator] -- other columns )
To better test this for you, please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).Do not include sensitive information or anything not related to the issue or question.
Additionly, please show the expected outcome based on the sample data you provided.
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Karolina411
Helper V
https://drive.google.com/drive/folders/1f2dNUj2ZOOsdVaW3B2TXNAFVuO_ALEGF?usp=sharing
Above are 3 files that may help. Is there a guide on how to transfer from report builder (.rdl files) to .pbix files? This data is being pre-processed in a VS model.
- Year slicer: Use