Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Need some help from the community.
I am trying to get the count of programs for each month (date as lastdayofthemonth) with target as above. However if for any month, there are no program with target as 'Above' then the measure should return 0.
Sample data
MonthYear | Program | Location | Project | Target (Below/Above) | LastdayofMonth |
1/1/2020 | ABC | Hyd | p1 | below | 1/31/2020 |
1/1/2020 | XYZ | Hyd | p2 | below | 1/31/2020 |
1/1/2020 | TEST1 | Hyd | p1 | below | 1/31/2020 |
1/1/2020 | ABC | Hyd | p2 | below | 1/31/2020 |
1/1/2020 | XYZ | Hyd | p2 | below | 1/31/2020 |
1/1/2020 | cb1 | blr | p2 | within | 1/31/2020 |
1/1/2020 | dum | blr | p2 | within | 1/31/2020 |
1/1/2020 | vix | blr | p2 | within | 1/31/2020 |
1/1/2020 | bull | blr | p2 | within | 1/31/2020 |
12/1/2019 | ABC | Hyd | p1 | below | 12/31/2019 |
12/1/2019 | XYZ | Hyd | p2 | below | 12/31/2019 |
12/1/2019 | TEST1 | Hyd | p1 | above | 12/31/2019 |
12/1/2019 | ABC | Hyd | p2 | below | 12/31/2019 |
12/1/2019 | XYZ | Hyd | p2 | below | 12/31/2019 |
12/1/2019 | cb1 | blr | p2 | within | 12/31/2019 |
12/1/2019 | dum | blr | p2 | below | 12/31/2019 |
12/1/2019 | vix | blr | p2 | within | 12/31/2019 |
12/1/2019 | bull | blr | p2 | within | 12/31/2019 |
11/1/2019 | ABC | Hyd | p1 | below | 11/30/2019 |
11/1/2019 | XYZ | Hyd | p2 | below | 11/30/2019 |
11/1/2019 | TEST1 | Hyd | p1 | within | 11/30/2019 |
11/1/2019 | ABC | Hyd | p2 | above | 11/30/2019 |
11/1/2019 | XYZ | Hyd | p2 | below | 11/30/2019 |
11/1/2019 | cb1 | blr | p2 | within | 11/30/2019 |
11/1/2019 | dum | blr | p2 | below | 11/30/2019 |
11/1/2019 | vix | blr | p2 | within | 11/30/2019 |
11/1/2019 | bull | blr | p2 | within | 11/30/2019 |
Solved! Go to Solution.
Your source data doesn't have an "Above" record for Jan 31, 2020. The measure will return "0" with no issue, but your data table doesn't have a row with "Above" on it to provide any filter context for the measure to work.
You may want to create a Dimension table with Above, Below, and Within, and use that table to populate your visuals, creating a One-To-Many to your Fact table, then everything will have an Above/Below/Within, and the measure would then work.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThank You @edhans for quick solution.
However the measure works unitl the Target is not added to the table visual.
Below in the highlighted Visual count for "Above" is missng for January.
Is there a way to fix this.
Thank Again.
Your source data doesn't have an "Above" record for Jan 31, 2020. The measure will return "0" with no issue, but your data table doesn't have a row with "Above" on it to provide any filter context for the measure to work.
You may want to create a Dimension table with Above, Below, and Within, and use that table to populate your visuals, creating a One-To-Many to your Fact table, then everything will have an Above/Below/Within, and the measure would then work.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingGreat @prab. Glad it works for you.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reportingtry
Measure = CALCULATE(DISTINCTCOUNT('Table'[Program]),'Table'[Target (Below/Above)]="Above")+0
If your measure is correctly returning what you want, and the issue is if it returns blank you want it to return 0 instead, use this:
Measure =
VAR ProgramCount =
CALCULATE(
DISTINCTCOUNT( 'Table'[Program] ),
'Table'[Target (Below/Above)] = "Above"
)
RETURN
IF(
ProgramCount = BLANK(),
0,
ProgramCount
)
It simply says if ProgramCount (which is your measure in the VAR statement) is blank, return 0, otherwise the value of ProgramCount.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCheck out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.